


***** Crisis and Convergence Article - Study 2: Individual-Level Analysis (1950 - 2016) : 29/09/20) *****

********* Data Analysed using Stata14 *********


** Install Data**

version 14
clear all
set more off, perm
numlabel, add
set scrollbufsize 300000
graph set window fontface "Times New Roman"

global data2 "C:\Users\zack\Documents\CrisisPaperReplicationData"     //* Alter accordingly

use $data2\cses_imd          //* CSES 1996-2016 Trendfile (Stata) 

*** Meta Variables ***

keep IMD1004 IMD1005 IMD1006_NAM IMD1008_YEAR IMD1008_MOD_1 IMD1008_MOD_2 IMD1008_MOD_3 ///
IMD1008_MOD_4 IMD1008_RES IMD1009 IMD1010_1 IMD1010_2 IMD1010_3  IMD1015 IMD2001_1 ///
IMD2002 IMD2003 IMD2004 IMD2005 IMD2006 IMD2007 IMD3001_LH IMD3002_LH_PL ///
IMD3002_LH_DC IMD3005_1 IMD3005_2 IMD3005_3 IMD3005_4 IMD3006 IMD3007_A IMD3007_B ///
IMD3007_C IMD3007_D IMD3007_E IMD3007_F IMD3007_G IMD3007_H IMD3007_I IMD3010 ///
IMD3011 IMD3012 IMD3013_1 IMD3013_2 IMD3013_3 IMD5000_A-IMD5000_I

rename IMD1005 respondent_ID
encode IMD1006_NAM, gen(country_FE)
encode IMD1004, gen(countryelection_FE)
rename IMD1008_YEAR year_FE

label variable respondent_ID "Respondent ID"
label variable country_FE "Fixed-Effect for Country"
label variable countryelection_FE "Fixed-Effect for Country-Election Year"
label variable year_FE "Fixed-Effect for Election Year"

gen westdem =.
label variable westdem "Dummy Variable for Advanced Western Parliamentary Democracy"
replace westdem = 0 if inlist(country_FE,1,2,5,7,8,10,11,12,14,20,21,24,26,27,28,29,30,31,32,36,37,38,40,41,42,43,44,45,46,50,51,52,53,54,55)
replace westdem = 1 if westdem != 0
drop if westdem != 1  //* Drop countries which are not advanced western parliamentary (or semi-parliamentary) democracies

gen parlelec =.
label variable parlelec "Dummy Variable for a Parliamentary Election (Lower House)"
replace parlelec = 0 if inrange(IMD3002_LH_PL,9999995,9999996) & inrange(IMD3002_LH_DC,9999995,9999996)
replace parlelec = 1 if parlelec != 0
drop if parlelec != 1 //* Drop non-parliamentary elections to the lower house 

gen post_crisis =.
replace post_crisis = 1 if year_FE > 2007
replace post_crisis = 0 if post_crisis != 1
label variable post_crisis "Dummy Variable for Post-Financial Crisis Election"

gen cses_wave =.
replace cses_wave = 1 if IMD1008_MOD_1 == 1
replace cses_wave = 2 if IMD1008_MOD_2 == 1
replace cses_wave = 3 if IMD1008_MOD_3 == 1
replace cses_wave = 4 if IMD1008_MOD_4 == 1
label variable cses_wave "Fixed-Effect for CSES Study Wave"
label define cses_wave 1 "Wave 1 (1996-01)" 2 "Wave 2 (2001-06)" 3 "Wave 3 (2006-11)" 4 "Wave 4 (2011-16)"
label values cses_wave cses_wave

rename IMD1015 study_type
label variable study_type "Pre- or Post-Electon Study?"

order cses_wave country_FE year_FE countryelection_FE post_crisis respondent_ID, before(IMD1004)

drop IMD1004 - IMD1008_RES
drop IMD1009

rename IMD1010_1 Weight_Survey 
rename IMD1010_2 Weight_Demographic
rename IMD1010_3 Weight_Political 

label variable Weight_Survey "Election Study Weight: Survey"
label variable Weight_Demographic "Election Study Weight: Demographic"
label variable Weight_Political "Election Study Weight: Political"

order study_type, after (respondent_ID)

drop westdem parlelec

*** Demographic Variables ***

gen age = IMD2001_1 if IMD2001_1 < 116
label variable age "Respondent Age (Years)"

recode age (16/24 = 1 "18-24") (25/44 = 2 "25-44") (45/64 = 3 "45-64") (65/115 = 4 "65+") (else=.), gen(age_4cat)
label variable age_4cat "Age (4 Categories)"

recode age (16/34 = 1 "18-34") (35/64 = 2 "35-64") (65/115 = 3 "65+") (else=.), gen(age_3cat)
label variable age_3cat "Age (3 Categories)"

recode IMD2002 (1 = 0 "Male") (2 = 1 "Female") (else=.), gen(gender)
label variable gender "Dummy Variable for Gender (1=Female)"

recode IMD2003 (0 = 0 "No Qualifications") (1 = 1 "Primary / Lower Secondary") (2 = 2 "Higher Secondary") (3 = 3 "Post-Secondary, Non-Uni") ///
               (6 = 3) (4 = 4 "University Qualifications") (else=.), gen(education_5cat)
			   
recode IMD2003 (0/1 = 0 "Pre-16 Qual") (2 = 1 "Completed Secondary") (3 = 2 "Post-Secondary, Non-Uni") ///
               (6 = 2) (4 = 3 "University Qualifications") (else=.), gen(education_4cat)		   			    
			   
recode IMD2003 (0/1 = 0 "Pre-16 Qual") (2/3 = 1 "Completed secondary and maybe some FE, Non-Uni") ///
               (6 = 1) (4 = 2 "University Qualifications") (8 = 1) (else=.), gen(education_3cat)			   			   		   
						   
recode IMD2003 (4 = 1 "Degree-Level Qualifications") (0/3 = 0 "No Degree") (8=0) (6=0) (else=.), gen(education_degree)

label variable education_5cat "Highest Educational Qualification (5 Categories)"
label variable education_4cat "Highest Educational Qualification (4 Categories)"
label variable education_3cat "Highest Educational Qualification (3 Categories)"
label variable education_degree "Dummy Variable for Degree-Qualifications"

recode IMD2004 (1 = 1 "Married or Living as Married") (2 = 2 "Widowed") (3 = 3 "Divorced or Separated") (4 = 4 "Single, Never Married") (else=.), gen(marital_status)
label variable marital_status "Marital Status (4 Categories)"

recode IMD2004 (1 = 1 "Married or Living as Married") (2/3 = 2 "Widowed or Divorced/Separated") (4 = 3 "Single, Never Married") (else=.), gen(marital_status2)
label variable marital_status2 "Marital Status (3 Categories)"

recode IMD2004 (1 = 1 "Married or Living as Married") (2/4 = 0 "Not Currently Married") (else=.), gen(married)
label variable married "Dummy Variable for Married"

recode IMD2005 (1 = 1 "Catholic") (2 = 2 "Protestant") (3 = 3 "Orthodox") (4 = 4 "Other Christian") (5 = 5 "Jewish") (7 = 6 "Muslim") (8/11 = 7 "Other") ///
               (96 = 7) (12/13 = 8 "Non-Religious") (98 = 8) (else =.), gen(religion_8cat)
label variable religion_8cat "Religious Denomiantion (8 Categories)"

recode IMD2005 (1/4 = 1 "Christian") (5 = 2 "Jewish") (7 = 3 "Muslim") (8/11 = 4 "Other") ///
               (96 = 4) (12/13 = 5 "Non-Religious") (98 = 5) (else =.), gen(religion_5cat)
label variable religion_5cat "Religious Denomiantion (5 Categories)"
	   
gen majreligion =.
label variable majreligion "Respondent Belongs to the Majority Religion of their Country"
label define majreligion 1 "Majority Religion" 2 "Other Chistian" 3 "Non-Christian" 4 "Non-Religious"
label values majreligion majreligion

replace majreligion = 1 if religion_8cat == 2 & country_FE == 3 //* Australia (Prot)
replace majreligion = 1 if religion_8cat == 1 & country_FE == 4 //* Austria (Catholic)
replace majreligion = 1 if religion_8cat == 1 & country_FE == 6 //* Belgium (Catholic)
replace majreligion = 1 if religion_8cat == 1 & country_FE == 9 //* Canada (Catholic)
replace majreligion = 1 if religion_8cat == 2 & country_FE == 13 //* Denmark (Protestant)
replace majreligion = 1 if religion_8cat == 2 & country_FE == 15 //* Finland (Protestant)
replace majreligion = 1 if religion_8cat == 1 & country_FE == 16 //* France (Catholic)
replace majreligion = 1 if religion_8cat == 2 & country_FE == 17 //* Germany (Protestant)
replace majreligion = 1 if religion_8cat == 2 & country_FE == 18 //* Great Britain (Protestant)
replace majreligion = 1 if religion_8cat == 3 & country_FE == 19 //* Greece (Orthodox)
replace majreligion = 1 if religion_8cat == 2 & country_FE == 22 //* Iceland (Protestant)
replace majreligion = 1 if religion_8cat == 1 & country_FE == 23 //* Ireland (Catholic)
replace majreligion = 1 if religion_8cat == 1 & country_FE == 25 //* Italy (Catholic)
replace majreligion = 1 if religion_8cat == 1 & country_FE == 33 //* Netherlands (Catholic)
replace majreligion = 1 if religion_8cat == 2 & country_FE == 34 //* NZ (Protestant)
replace majreligion = 1 if religion_8cat == 2 & country_FE == 35 //* Norway (Protestant)
replace majreligion = 1 if religion_8cat == 1 & country_FE == 39 //* Portugal (Catholic)
replace majreligion = 1 if religion_8cat == 1 & country_FE == 47 //* Spain (Catholic)
replace majreligion = 1 if religion_8cat == 2 & country_FE == 48 //* Sweden (Protestant)
replace majreligion = 1 if religion_8cat == 1 & country_FE == 49 //* Switzerland (Catholic)

replace majreligion = 2 if majreligion != 1 & inrange(religion_8cat,1,4)
replace majreligion = 3 if majreligion != 1 & inrange(religion_8cat,5,7)
replace majreligion = 4 if majreligion != 1 & religion_8cat == 8
	     	   
gen majreligion2 =.
label variable majreligion2 "Respondent Belongs to the Majority Religion of their Country (Dummy)"
label define majreligion2 1 "Majority Religion" 0 "Not a Follower of Major Religion"
label values majreligion2 majreligion2	   

replace majreligion2 = 1 if majreligion == 1	   
replace majreligion2 = 0 if majreligion != 1	   
replace majreligion2 =.  if majreligion ==.	   
	   
gen income_group_5 =.
label define income_group_5 1 "Lowest household income quintile" 2 "Second household income quintile" ///
                            3 "Third household income quintile" 4 "Fouth household income quintile" ///
							5 "Highest household income quintile", replace
							
label values income_group_5 income_group_5
label variable income_group_5 "Household Income (Quintiles)"

replace income_group = 1 if IMD2006 == 1
replace income_group = 2 if IMD2006 == 2
replace income_group = 3 if IMD2006 == 3
replace income_group = 4 if IMD2006 == 4
replace income_group = 5 if IMD2006 == 5	   
	   
recode IMD2007 (1 = 1 "Rural Area or Village") (2 = 2 "Small or Medium-Sized Town") (3 = 3 "Suburbs of Major Urban Area") ///
               (4 = 4 "Large Town or City") (else=.), gen(location)
label variable location "Location of Respondent (Rural, Urban, Suburban...etc)"
 	   
drop IMD2001_1 - IMD2007

order age - location, after(respondent_ID)


*** Political Variables (Attitudinal) *** 

recode IMD3010 (1 = 5 "Very Satisfied") (2 = 4 "Fairly Satisfied") (6 = 3 "Neither Satisfied nor Unsatisfied") ///
               (4 = 2 "Nor very Satisfied") (5 = 1 "Not at all Satisfied") (else =.) , gen(dem_sat)
label variable dem_sat "Satisfaction with Democracy"
 
recode IMD3010 (1 = 5 "Very Satisfied") (2 = 4 "Fairly Satisfied") (6 = 3 "Neither Satisfied nor Unsatisfied") ///
               (4 = 2 "Nor very Satisfied") (5 = 1 "Not at all Satisfied") (8=3) (else =.) , gen(dem_sat2)
label variable dem_sat2 "Satisfaction with Democracy (DK = Centre)"	   
	   
recode IMD3011 (1 = 1 "It doesn't make any difference who is in power") (2=2) (3=3) (4=4) (5=5 "It makes a big difference who is in power") (else=.), gen(effic_power)
label variable effic_power "Does it make a difference who is in power?"
   
recode IMD3011 (1 = 1 "It doesn't make any difference who is in power") (2=2) (3=3) (4=4) (5=5 "It makes a big difference who is in power") (8=3) (else=.), gen(effic_power2)
label variable effic_power2 "Does it make a difference who is in power? (DK = Centre)"	   

recode IMD3012 (1 = 1 "It doesn't make any difference who people vote for") (2=2) (3=3) (4=4) (5=5 "It makes a big difference who people vote for") (else=.), gen(effic_vote)
label variable effic_vote "Does it make a difference who people vote for?"
   
recode IMD3012 (1 = 1 "It doesn't make any difference who people vote for") (2=2) (3=3) (4=4) (5=5 "It makes a big difference who people vote for") (8=3) (else=.), gen(effic_vote2)
label variable effic_vote2 "Does it make a difference who people vote for? (DK = Centre)"	  	   
   
gen econpos_5cat =.
label variable econpos_5cat "Perception of Positive Change in State of National Economy (Past 12 Months)"
label define econpos_5cat 1 "Economy got much worse" 2 "Economy got somewhat worse" ///
                            3 "No change" 4 "Economy got somewhat better" ///
							5 "Economy got much better", replace			
label values econpos_5cat econpos_5cat
 
replace econpos_5cat = 2 if IMD3013_1 == 5 & IMD3013_3 == 4 | IMD3013_3 == 4 | IMD3013_1 == 5 & inrange(IMD3013_3,7,9)
replace econpos_5cat = 1 if IMD3013_1 == 5 & IMD3013_3 == 5 | IMD3013_3 == 5 
replace econpos_5cat = 3 if IMD3013_1 == 3	   
replace econpos_5cat = 4 if IMD3013_1 == 1 & IMD3013_2 == 2 | IMD3013_2 == 2 | IMD3013_1 == 1 & inrange(IMD3013_3,7,9)
replace econpos_5cat = 5 if IMD3013_1 == 1 & IMD3013_2 == 1 | IMD3013_2 == 1    
	   
gen econpos_3cat =.
label variable econpos_3cat "Perception of Positive Change in State of National Economy (Past 12 Months)"
label define econpos_3cat 1 "Economy got worse" 2 "No change" ///
                            3 "Economy got better", replace			
label values econpos_3cat econpos_3cat
	   
replace econpos_3cat = 1 if IMD3013_1 == 5 
replace econpos_3cat = 2 if IMD3013_1 == 3
replace econpos_3cat = 3 if IMD3013_1 == 1	   
	   
gen econpos_5cat2 =.
label variable econpos_5cat2 "Perception of Positive Change in State of National Economy (DK = Centre)"
label define econpos_5cat2 1 "Economy got much worse" 2 "Economy got somewhat worse" ///
                            3 "No change" 4 "Economy got somewhat better" ///
							5 "Economy got much better", replace			
label values econpos_5cat2 econpos_5cat2
	   
replace econpos_5cat2 = 2 if IMD3013_1 == 5 & IMD3013_3 == 4 | IMD3013_3 == 4 | IMD3013_1 == 5 & inrange(IMD3013_3,7,9)
replace econpos_5cat2 = 1 if IMD3013_1 == 5 & IMD3013_3 == 5 | IMD3013_3 == 5 
replace econpos_5cat2 = 3 if IMD3013_1 == 3	| IMD3013_1 == 8  
replace econpos_5cat2 = 4 if IMD3013_1 == 1 & IMD3013_2 == 2 | IMD3013_2 == 2 | IMD3013_1 == 1 & inrange(IMD3013_3,7,9)
replace econpos_5cat2 = 5 if IMD3013_1 == 1 & IMD3013_2 == 1 | IMD3013_2 == 1    
	   
gen econpos_3cat2 =.
label variable econpos_3cat2 "Perception of Positive Change in State of National Economy (DK = Centre)"
label define econpos_3cat2 1 "Economy got worse" 2 "No change" ///
                            3 "Economy got better", replace			
label values econpos_3cat2 econpos_3cat2
	   
replace econpos_3cat2 = 1 if IMD3013_1 == 5 
replace econpos_3cat2 = 2 if IMD3013_1 == 3 | IMD3013_1 == 8 
replace econpos_3cat2 = 3 if IMD3013_1 == 1	   
	   
drop IMD3010 - IMD3013_3
order dem_sat - econpos_3cat2, after(location)	   


gen self_LR =.
label variable self_LR "Respondent L-R self-placement scale?"
label define self_LR 1 "Far Left" 11 "Far Right" 5 "Centre-Left" 6 "Centre" 7 "Centre-Right", replace
label values self_LR self_LR
	 
replace self_LR = 1 if IMD3006 == 0
replace self_LR = 2 if IMD3006 == 1
replace self_LR = 3 if IMD3006 == 2
replace self_LR = 4 if IMD3006 == 3
replace self_LR = 5 if IMD3006 == 4
replace self_LR = 6 if IMD3006 == 5 
replace self_LR = 7 if IMD3006 == 6
replace self_LR = 8 if IMD3006 == 7
replace self_LR = 9 if IMD3006 == 8
replace self_LR = 10 if IMD3006 == 9
replace self_LR = 11 if IMD3006 == 10

recode self_LR (1 = -5) (2 = -4) (3 = -3) (4 = -2) (5 = -1) (6 = 0) (7 = 1) (8 = 2) (9 = 3) (10 = 4) (11 = 5) (else=.), gen(recode_selfLR)
gen self_rad = recode_selfLR^2
label variable self_rad "Respondent self-percep distance from centre of L-R spectrum"
replace self_rad = sqrt(self_rad)

gen self_LR2 =.
label variable self_LR2 "Respondent L-R self-placement scale? (DK = Centre)"
label define self_LR2 1 "Far Left" 11 "Far Right" 5 "Centre-Left" 6 "Centre" 7 "Centre-Right", replace
label values self_LR2 self_LR2

replace self_LR2 = 1 if IMD3006 == 0
replace self_LR2 = 2 if IMD3006 == 1
replace self_LR2 = 3 if IMD3006 == 2
replace self_LR2 = 4 if IMD3006 == 3
replace self_LR2 = 5 if IMD3006 == 4
replace self_LR2 = 6 if IMD3006 == 5 | IMD3006 == 98
replace self_LR2 = 7 if IMD3006 == 6
replace self_LR2 = 8 if IMD3006 == 7
replace self_LR2 = 9 if IMD3006 == 8
replace self_LR2 = 10 if IMD3006 == 9
replace self_LR2 = 11 if IMD3006 == 10

recode self_LR2 (1 = -5) (2 = -4) (3 = -3) (4 = -2) (5 = -1) (6 = 0) (7 = 1) (8 = 2) (9 = 3) (10 = 4) (11 = 5) (else=.), gen(recode_selfLR2)
gen self_rad2 = recode_selfLR2^2
label variable self_rad2 "Respondent self-percep distance from centre of L-R spectrum (DK = Centre)"
replace self_rad2 = sqrt(self_rad2)

drop recode_selfLR* IMD3006
order self_LR- self_rad2, after(econpos_3cat2)
	   
	   
*** Mainstream Party L-R Position Evaluation  *** 

rename IMD3007_* LReval_Party*

foreach var of varlist LReval_Party* {
        replace `var' =. if `var' > 11
		replace `var' = `var' + 1
}


label variable LReval_PartyA "Individual L-R (1-11) evaluation of party #A"
label variable LReval_PartyB "Individual L-R (1-11) evaluation of party #B"
label variable LReval_PartyC "Individual L-R (1-11) evaluation of party #C"
label variable LReval_PartyD "Individual L-R (1-11) evaluation of party #D"
label variable LReval_PartyE "Individual L-R (1-11) evaluation of party #E"
label variable LReval_PartyF "Individual L-R (1-11) evaluation of party #F"
label variable LReval_PartyG "Individual L-R (1-11) evaluation of party #G"
label variable LReval_PartyH "Individual L-R (1-11) evaluation of party #H"
label variable LReval_PartyI "Individual L-R (1-11) evaluation of party #I"

label define party_LR 1 "Far Left" 11 "Far Right" 5 "Centre-Left" 6 "Centre" 7 "Centre-Right", replace
label values LReval_Party* party_LR


bysort countryelection: egen avLReval_PartyA = mean(LReval_PartyA)
bysort countryelection: egen avLReval_PartyB = mean(LReval_PartyB)
bysort countryelection: egen avLReval_PartyC = mean(LReval_PartyC)
bysort countryelection: egen avLReval_PartyD = mean(LReval_PartyD)
bysort countryelection: egen avLReval_PartyE = mean(LReval_PartyE)
bysort countryelection: egen avLReval_PartyF = mean(LReval_PartyF)
bysort countryelection: egen avLReval_PartyG = mean(LReval_PartyG)
bysort countryelection: egen avLReval_PartyH = mean(LReval_PartyH)
bysort countryelection: egen avLReval_PartyI = mean(LReval_PartyI)

label variable avLReval_PartyA "Average individual L-R (1-11) evaluation of party #A"
label variable avLReval_PartyB "Average individual L-R (1-11) evaluation of party #B"
label variable avLReval_PartyC "Average individual L-R (1-11) evaluation of party #C"
label variable avLReval_PartyD "Average individual L-R (1-11) evaluation of party #D"
label variable avLReval_PartyE "Average individual L-R (1-11) evaluation of party #E"
label variable avLReval_PartyF "Average individual L-R (1-11) evaluation of party #F"
label variable avLReval_PartyG "Average individual L-R (1-11) evaluation of party #G"
label variable avLReval_PartyH "Average individual L-R (1-11) evaluation of party #H"
label variable avLReval_PartyI "Average individual L-R (1-11) evaluation of party #I"

label values LReval_Party* party_LR


**** Rad Score ****

gen party_typeA =.
label variable party_typeA "Type of Party - A"
gen party_typeB =.
label variable party_typeB "Type of Party - B"
gen party_typeC =.
label variable party_typeC "Type of Party - C"
gen party_typeD =.
label variable party_typeD "Type of Party - D"
gen party_typeE =.
label variable party_typeE "Type of Party - E"
gen party_typeF =.
label variable party_typeF "Type of Party - F"
gen party_typeG =.
label variable party_typeG "Type of Party - G"
gen party_typeH =.
label variable party_typeH "Type of Party - H"
gen party_typeI =.
label variable party_typeI "Type of Party - I"

label define party_type 1 "Mainstream" 2 "Complementary" 3 "Half-Way House" 4 "Anti-System Party", replace
label values party_type* party_type


gen vote_partyA =.
gen vote_partyB =.
gen vote_partyC =.
gen vote_partyD =.
gen vote_partyE =.
gen vote_partyF =.
gen vote_partyG =.
gen vote_partyH =.
gen vote_partyI =.

label variable vote_partyA "Vote Share Party A"  //* Vote shares from Agg Chapter Sources.
label variable vote_partyB "Vote Share Party B"
label variable vote_partyC "Vote Share Party C"
label variable vote_partyD "Vote Share Party D"
label variable vote_partyE "Vote Share Party E"
label variable vote_partyF "Vote Share Party F" 
label variable vote_partyG "Vote Share Party G" 
label variable vote_partyH "Vote Share Party H" 
label variable vote_partyI "Vote Share Party I" 

* Australia 96
replace party_typeA = 1 if countryelection_FE == 3 //* Australian Labour Party
replace party_typeB = 1 if countryelection_FE == 3 //* Australian Liberal Party
replace party_typeC = 1 if countryelection_FE == 3 //* National Party of Australia
replace party_typeD = 2 if countryelection_FE == 3 //* Australian Democrats
replace party_typeE = 4 if countryelection_FE == 3 //* Australian Greens
replace party_typeF = . if countryelection_FE == 3
replace party_typeG = . if countryelection_FE == 3
replace party_typeH = . if countryelection_FE == 3
replace party_typeI = . if countryelection_FE == 3

replace vote_partyA = 38.8  if countryelection_FE == 3 
replace vote_partyB = 38.7  if countryelection_FE == 3 
replace vote_partyC =  8.5  if countryelection_FE == 3 
replace vote_partyD =  6.8  if countryelection_FE == 3 
replace vote_partyE =  2.9  if countryelection_FE == 3 
replace vote_partyF = .  if countryelection_FE == 3 
replace vote_partyG = .  if countryelection_FE == 3 
replace vote_partyH = .  if countryelection_FE == 3 
replace vote_partyI = .  if countryelection_FE == 3 

* Australia 04
replace party_typeA = 1 if countryelection_FE == 4 //* Australian Liberal Party
replace party_typeB = 1 if countryelection_FE == 4 //* Australian Labour Party
replace party_typeC = 4 if countryelection_FE == 4 //* Australian Green Party
replace party_typeD = 1 if countryelection_FE == 4 //* National Party of Australian Party
replace party_typeE = 2 if countryelection_FE == 4 //* Family First Party
replace party_typeF = 2 if countryelection_FE == 4 //* Australian Democrats
replace party_typeG = 4 if countryelection_FE == 4 //* One Nation Party
replace party_typeH = . if countryelection_FE == 4
replace party_typeI = . if countryelection_FE == 4

replace vote_partyA = 40.5  if countryelection_FE == 4 
replace vote_partyB = 37.6  if countryelection_FE == 4 
replace vote_partyC = 7.2   if countryelection_FE == 4 
replace vote_partyD = 5.9   if countryelection_FE == 4 
replace vote_partyE = 2.0   if countryelection_FE == 4 
replace vote_partyF = 1.2   if countryelection_FE == 4 
replace vote_partyG = 1.2   if countryelection_FE == 4 
replace vote_partyH =  . if countryelection_FE == 4 
replace vote_partyI =  . if countryelection_FE == 4 

* Australia 07
replace party_typeA = 1 if countryelection_FE == 5 //* Australian Labour Party
replace party_typeB = 1 if countryelection_FE == 5 //* Australian Liberal Party
replace party_typeC = 1 if countryelection_FE == 5 //* National Party of Australian Party
replace party_typeD = 4 if countryelection_FE == 5 //* Australian Green Party
replace party_typeE = . if countryelection_FE == 5
replace party_typeF = . if countryelection_FE == 5
replace party_typeG = . if countryelection_FE == 5
replace party_typeH = . if countryelection_FE == 5
replace party_typeI = . if countryelection_FE == 5

replace vote_partyA = 43.4  if countryelection_FE == 5 
replace vote_partyB = 36.6  if countryelection_FE == 5 
replace vote_partyC =  5.5  if countryelection_FE == 5 
replace vote_partyD =  7.8  if countryelection_FE == 5 
replace vote_partyE =   . if countryelection_FE == 5 
replace vote_partyF =   . if countryelection_FE == 5 
replace vote_partyG =   . if countryelection_FE == 5 
replace vote_partyH =   . if countryelection_FE == 5 
replace vote_partyI =   . if countryelection_FE == 5 

* Australia 13
replace party_typeA = 1 if countryelection_FE == 6 //* Australian Liberal Party
replace party_typeB = 1 if countryelection_FE == 6 //* Australian Labour Party
replace party_typeC = 1 if countryelection_FE == 6 //* Australian Greens
replace party_typeD = 2 if countryelection_FE == 6 //* Palmer UTD
replace party_typeE = 1 if countryelection_FE == 6 //* National Party Australia
replace party_typeF = . if countryelection_FE == 6
replace party_typeG = . if countryelection_FE == 6
replace party_typeH = . if countryelection_FE == 6
replace party_typeI = . if countryelection_FE == 6

replace vote_partyA = 32.0  if countryelection_FE == 6 
replace vote_partyB = 33.4  if countryelection_FE == 6 
replace vote_partyC =  8.7  if countryelection_FE == 6 
replace vote_partyD =  5.5  if countryelection_FE == 6 
replace vote_partyE =  8.9  if countryelection_FE == 6 
replace vote_partyF =   . if countryelection_FE == 6 
replace vote_partyG =   . if countryelection_FE == 6 
replace vote_partyH =   . if countryelection_FE == 6 
replace vote_partyI =   . if countryelection_FE == 6 

* Austria 08
replace party_typeA = 1 if countryelection_FE == 7 //* SPO
replace party_typeB = 1 if countryelection_FE == 7 //* OVP
replace party_typeC = 4 if countryelection_FE == 7 //* FPO
replace party_typeD = 3 if countryelection_FE == 7 //* BZO
replace party_typeE = 2 if countryelection_FE == 7 //* Greens
replace party_typeF = 1 if countryelection_FE == 7 //* Liberal Forum
replace party_typeG = 2 if countryelection_FE == 7 //* Citizen Forum
replace party_typeH = . if countryelection_FE == 7
replace party_typeI = . if countryelection_FE == 7

replace vote_partyA = 29.3  if countryelection_FE == 7 
replace vote_partyB = 26.0  if countryelection_FE == 7 
replace vote_partyC = 17.5  if countryelection_FE == 7 
replace vote_partyD = 10.7  if countryelection_FE == 7 
replace vote_partyE = 10.4  if countryelection_FE == 7 
replace vote_partyF =  2.1  if countryelection_FE == 7 
replace vote_partyG =  1.8  if countryelection_FE == 7 
replace vote_partyH =   . if countryelection_FE == 7 
replace vote_partyI =   . if countryelection_FE == 7 

* Austria 13
replace party_typeA = 1 if countryelection_FE == 8 //* SPO
replace party_typeB = 1 if countryelection_FE == 8 //* OVP
replace party_typeC = 4 if countryelection_FE == 8 //* FPO
replace party_typeD = 2 if countryelection_FE == 8 //* Greens
replace party_typeE = 1 if countryelection_FE == 8 //* BZO
replace party_typeF = 2 if countryelection_FE == 8 //* NEOS
replace party_typeG = 4 if countryelection_FE == 8 //* Team Stronach
replace party_typeH = 4 if countryelection_FE == 8 //* Communists
replace party_typeI = 4 if countryelection_FE == 8 //* Pirate Party

replace vote_partyA = 26.8 if countryelection_FE == 8 
replace vote_partyB = 24.0  if countryelection_FE == 8 
replace vote_partyC = 20.5  if countryelection_FE == 8 
replace vote_partyD = 12.4  if countryelection_FE == 8 
replace vote_partyE =  3.5 if countryelection_FE == 8 
replace vote_partyF =  5.0 if countryelection_FE == 8 
replace vote_partyG =  5.7 if countryelection_FE == 8 
replace vote_partyH =  1.0 if countryelection_FE == 8 
replace vote_partyI =  0.8 if countryelection_FE == 8 

* Flanders 99
replace party_typeA = 1 if countryelection_FE == 9 //* Flemish Liberals
replace party_typeB = 1 if countryelection_FE == 9 //* Christian Democratic
replace party_typeC = 1 if countryelection_FE == 9 //* Socialist Party
replace party_typeD = 4 if countryelection_FE == 9 //* Flemish Bloc
replace party_typeE = 2 if countryelection_FE == 9 //* Greens
replace party_typeF = 1 if countryelection_FE == 9 //* People's Union
replace party_typeG = . if countryelection_FE == 9
replace party_typeH = . if countryelection_FE == 9
replace party_typeI = . if countryelection_FE == 9

replace vote_partyA =  22.8 if countryelection_FE == 9 
replace vote_partyB =  22.6 if countryelection_FE == 9 
replace vote_partyC =  15.6 if countryelection_FE == 9 
replace vote_partyD =  15.4 if countryelection_FE == 9 
replace vote_partyE =  11.4 if countryelection_FE == 9 
replace vote_partyF =   8.8 if countryelection_FE == 9 
replace vote_partyG =    . if countryelection_FE == 9 
replace vote_partyH =    . if countryelection_FE == 9 
replace vote_partyI =    . if countryelection_FE == 9 

* Wallonia 99
replace party_typeA = 1 if countryelection_FE == 10 //* Socialists
replace party_typeB = 1 if countryelection_FE == 10 //* Libs-FDF
replace party_typeC = 2 if countryelection_FE == 10 //* Greens
replace party_typeD = 1 if countryelection_FE == 10 //* Christian Dem
replace party_typeE = 4 if countryelection_FE == 10 //* National Front
replace party_typeF = 2 if countryelection_FE == 10 //* Vivant
replace party_typeG = . if countryelection_FE == 10
replace party_typeH = . if countryelection_FE == 10
replace party_typeI = . if countryelection_FE == 10

replace vote_partyA = 29.2  if countryelection_FE == 10 
replace vote_partyB = 24.7  if countryelection_FE == 10 
replace vote_partyC = 18.3  if countryelection_FE == 10 
replace vote_partyD = 16.8  if countryelection_FE == 10 
replace vote_partyE =  4.1  if countryelection_FE == 10 
replace vote_partyF =  2.5  if countryelection_FE == 10 
replace vote_partyG =   . if countryelection_FE == 10 
replace vote_partyH =   . if countryelection_FE == 10 
replace vote_partyI =   . if countryelection_FE == 10 

* Belgium 03 (NA, no LR Party Ratings)
replace party_typeA = 1 if countryelection_FE == 11 //* Liberals
replace party_typeB = 1 if countryelection_FE == 11 //* Socialists
replace party_typeC = 1 if countryelection_FE == 11 //* ChristDem
replace party_typeD = 1 if countryelection_FE == 11 //* French Socialists
replace party_typeE = 4 if countryelection_FE == 11 //* Flemish Bloc
replace party_typeF = 1 if countryelection_FE == 11 //* French Libs
replace party_typeG = 1 if countryelection_FE == 11 //* French Christ Dem
replace party_typeH = 4 if countryelection_FE == 11 //* NVA
replace party_typeI = 1 if countryelection_FE == 11 //* Greens

replace vote_partyA = 15.4  if countryelection_FE == 11 
replace vote_partyB = 14.9  if countryelection_FE == 11 
replace vote_partyC = 13.3  if countryelection_FE == 11 
replace vote_partyD = 13.0  if countryelection_FE == 11 
replace vote_partyE = 11.6  if countryelection_FE == 11 
replace vote_partyF = 11.4  if countryelection_FE == 11 
replace vote_partyG =  5.5 if countryelection_FE == 11 
replace vote_partyH =  3.1 if countryelection_FE == 11 
replace vote_partyI =  3.1 if countryelection_FE == 11 

* Canada 97
replace party_typeA = 1 if countryelection_FE == 20 //* Liberals
replace party_typeB = 4 if countryelection_FE == 20 //* Reform Party
replace party_typeC = 1 if countryelection_FE == 20 //* Progressive Cons
replace party_typeD = 1 if countryelection_FE == 20 //* NDP
replace party_typeE = 4 if countryelection_FE == 20 //* Quebec Bloc
replace party_typeF = . if countryelection_FE == 20
replace party_typeG = . if countryelection_FE == 20
replace party_typeH = . if countryelection_FE == 20
replace party_typeI = . if countryelection_FE == 20

replace vote_partyA = 38.5  if countryelection_FE == 20 
replace vote_partyB = 19.4  if countryelection_FE == 20 
replace vote_partyC = 18.8  if countryelection_FE == 20 
replace vote_partyD = 11.0  if countryelection_FE == 20 
replace vote_partyE = 10.7  if countryelection_FE == 20 
replace vote_partyF =   . if countryelection_FE == 20 
replace vote_partyG =   . if countryelection_FE == 20 
replace vote_partyH =   . if countryelection_FE == 20 
replace vote_partyI =   . if countryelection_FE == 20 

* Canada 04
replace party_typeA = 1 if countryelection_FE == 21 //* Liberals
replace party_typeB = 1 if countryelection_FE == 21 //* Conservative Party
replace party_typeC = 1 if countryelection_FE == 21 //* NDP
replace party_typeD = 4 if countryelection_FE == 21 //* QB
replace party_typeE = 2 if countryelection_FE == 21 //* Greens
replace party_typeF = . if countryelection_FE == 21
replace party_typeG = . if countryelection_FE == 21
replace party_typeH = . if countryelection_FE == 21
replace party_typeI = . if countryelection_FE == 21

replace vote_partyA = 36.7  if countryelection_FE == 21 
replace vote_partyB = 29.6  if countryelection_FE == 21 
replace vote_partyC = 15.7  if countryelection_FE == 21 
replace vote_partyD = 12.4  if countryelection_FE == 21 
replace vote_partyE =  4.3  if countryelection_FE == 21 
replace vote_partyF =   . if countryelection_FE == 21 
replace vote_partyG =   . if countryelection_FE == 21 
replace vote_partyH =   . if countryelection_FE == 21 
replace vote_partyI =   . if countryelection_FE == 21 

* Canada 08
replace party_typeA = 1 if countryelection_FE == 22 //* Conservative Party
replace party_typeB = 1 if countryelection_FE == 22 //* Liberals
replace party_typeC = 4 if countryelection_FE == 22 //* Quebec Bloc
replace party_typeD = 1 if countryelection_FE == 22 //* NDP
replace party_typeE = 2 if countryelection_FE == 22 //* Greens
replace party_typeF = . if countryelection_FE == 22
replace party_typeG = . if countryelection_FE == 22
replace party_typeH = . if countryelection_FE == 22
replace party_typeI = . if countryelection_FE == 22

replace vote_partyA = 37.7  if countryelection_FE == 22 
replace vote_partyB = 26.3  if countryelection_FE == 22 
replace vote_partyC = 10.0  if countryelection_FE == 22 
replace vote_partyD = 18.2  if countryelection_FE == 22 
replace vote_partyE =  6.8  if countryelection_FE == 22 
replace vote_partyF =   . if countryelection_FE == 22 
replace vote_partyG =   . if countryelection_FE == 22 
replace vote_partyH =   . if countryelection_FE == 22 
replace vote_partyI =   . if countryelection_FE == 22 

* Canada 11
replace party_typeA = 1 if countryelection_FE == 23 //* Conservative Party
replace party_typeB = 1 if countryelection_FE == 23 //* NDP
replace party_typeC = 1 if countryelection_FE == 23 //* Liberals
replace party_typeD = 4 if countryelection_FE == 23 //* BQ 
replace party_typeE = 2 if countryelection_FE == 23 //* Greens
replace party_typeF = . if countryelection_FE == 23
replace party_typeG = . if countryelection_FE == 23
replace party_typeH = . if countryelection_FE == 23
replace party_typeI = . if countryelection_FE == 23

replace vote_partyA = 39.6  if countryelection_FE == 23 
replace vote_partyB = 30.6  if countryelection_FE == 23 
replace vote_partyC = 18.9  if countryelection_FE == 23 
replace vote_partyD =  6.1  if countryelection_FE == 23 
replace vote_partyE =  3.9  if countryelection_FE == 23 
replace vote_partyF =   . if countryelection_FE == 23 
replace vote_partyG =   . if countryelection_FE == 23 
replace vote_partyH =   . if countryelection_FE == 23 
replace vote_partyI =   . if countryelection_FE == 23 

* Canada 15
replace party_typeA = 1 if countryelection_FE == 24 //* Liberals
replace party_typeB = 1 if countryelection_FE == 24 //* Conservatives
replace party_typeC = 1 if countryelection_FE == 24 //* NDP
replace party_typeD = 4 if countryelection_FE == 24 //* BQ 
replace party_typeE = 2 if countryelection_FE == 24 //* Greens
replace party_typeF = . if countryelection_FE == 24
replace party_typeG = . if countryelection_FE == 24
replace party_typeH = . if countryelection_FE == 24
replace party_typeI = . if countryelection_FE == 24

replace vote_partyA = 39.5  if countryelection_FE == 24 
replace vote_partyB = 31.9  if countryelection_FE == 24 
replace vote_partyC = 19.7  if countryelection_FE == 24 
replace vote_partyD =  4.7  if countryelection_FE == 24 
replace vote_partyE =  3.4  if countryelection_FE == 24 
replace vote_partyF =   . if countryelection_FE == 24 
replace vote_partyG =   . if countryelection_FE == 24 
replace vote_partyH =   . if countryelection_FE == 24 
replace vote_partyI =   . if countryelection_FE == 24 

* Switz 99
replace party_typeA = 3 if countryelection_FE == 25 //* Swiss People's
replace party_typeB = 1 if countryelection_FE == 25 //* SDP
replace party_typeC = 1 if countryelection_FE == 25 //* FDP
replace party_typeD = 1 if countryelection_FE == 25 //* Christ Dem
replace party_typeE = 2 if countryelection_FE == 25 //* Greens
replace party_typeF = 1 if countryelection_FE == 25 //* Liberals
replace party_typeG = . if countryelection_FE == 25
replace party_typeH = . if countryelection_FE == 25
replace party_typeI = . if countryelection_FE == 25

replace vote_partyA = 22.6  if countryelection_FE == 25 
replace vote_partyB = 22.5  if countryelection_FE == 25 
replace vote_partyC = 19.9  if countryelection_FE == 25 
replace vote_partyD = 15.8  if countryelection_FE == 25 
replace vote_partyE =  5.0  if countryelection_FE == 25 
replace vote_partyF =  2.2  if countryelection_FE == 25 
replace vote_partyG =   . if countryelection_FE == 25 
replace vote_partyH =   . if countryelection_FE == 25 
replace vote_partyI =   . if countryelection_FE == 25 

* Switz 03
replace party_typeA = 3 if countryelection_FE == 26 //* Swiss People's Party
replace party_typeB = 1 if countryelection_FE == 26 //* SDP
replace party_typeC = 1 if countryelection_FE == 26 //* FDP
replace party_typeD = 1 if countryelection_FE == 26 //* Christian Dem
replace party_typeE = 2 if countryelection_FE == 26 //* Greens
replace party_typeF = . if countryelection_FE == 26
replace party_typeG = . if countryelection_FE == 26
replace party_typeH = . if countryelection_FE == 26
replace party_typeI = . if countryelection_FE == 26

replace vote_partyA = 26.7  if countryelection_FE == 26 
replace vote_partyB = 23.3  if countryelection_FE == 26 
replace vote_partyC = 17.3  if countryelection_FE == 26 
replace vote_partyD = 14.4  if countryelection_FE == 26 
replace vote_partyE =  7.4  if countryelection_FE == 26 
replace vote_partyF =   . if countryelection_FE == 26 
replace vote_partyG =   . if countryelection_FE == 26 
replace vote_partyH =   . if countryelection_FE == 26 
replace vote_partyI =   . if countryelection_FE == 26 

* Switz 07
replace party_typeA = 3 if countryelection_FE == 27 //* Swiss People's Party
replace party_typeB = 1 if countryelection_FE == 27 //* SDP
replace party_typeC = 1 if countryelection_FE == 27 //* FDP
replace party_typeD = 1 if countryelection_FE == 27 //* Christian Dem
replace party_typeE = 2 if countryelection_FE == 27 //* Greens
replace party_typeF = 1 if countryelection_FE == 27 //* Evangelical PP
replace party_typeG = 1 if countryelection_FE == 27 //* Liberals
replace party_typeH = 4 if countryelection_FE == 27 //* Ticino League
replace party_typeI = . if countryelection_FE == 27

replace vote_partyA =  28.6 if countryelection_FE == 27 
replace vote_partyB =  19.3 if countryelection_FE == 27 
replace vote_partyC =  15.5 if countryelection_FE == 27 
replace vote_partyD =  14.3 if countryelection_FE == 27 
replace vote_partyE =   9.5 if countryelection_FE == 27 
replace vote_partyF =   2.4 if countryelection_FE == 27 
replace vote_partyG =   1.8 if countryelection_FE == 27 
replace vote_partyH =   0.6 if countryelection_FE == 27 
replace vote_partyI =    . if countryelection_FE == 27 

* Switz 11
replace party_typeA = 3 if countryelection_FE == 28 //* Swiss People's Party
replace party_typeB = 1 if countryelection_FE == 28 //* SDP
replace party_typeC = 1 if countryelection_FE == 28 //* FDP 
replace party_typeD = 1 if countryelection_FE == 28 //* ChristDem
replace party_typeE = 2 if countryelection_FE == 28 //* Greens
replace party_typeF = 1 if countryelection_FE == 28 //* Evangelical PP
replace party_typeG = 4 if countryelection_FE == 28 //* Ticino League
replace party_typeH = . if countryelection_FE == 28
replace party_typeI = . if countryelection_FE == 28

replace vote_partyA = 26.6  if countryelection_FE == 28 
replace vote_partyB = 18.7  if countryelection_FE == 28 
replace vote_partyC = 15.1  if countryelection_FE == 28 
replace vote_partyD = 12.3  if countryelection_FE == 28 
replace vote_partyE =  8.4  if countryelection_FE == 28 
replace vote_partyF =  2.0  if countryelection_FE == 28 
replace vote_partyG =  0.8  if countryelection_FE == 28 
replace vote_partyH =   . if countryelection_FE == 28 
replace vote_partyI =   . if countryelection_FE == 28 

* Germany 2002(1)
replace party_typeA = 1 if countryelection_FE == 37 //* SPD
replace party_typeB = 1 if countryelection_FE == 37 //* CDU
replace party_typeC = 1 if countryelection_FE == 37 //* CSU
replace party_typeD = 1 if countryelection_FE == 37 //* Greens
replace party_typeE = 1 if countryelection_FE == 37 //* FDP
replace party_typeF = 4 if countryelection_FE == 37 //* Left Party
replace party_typeG = 4 if countryelection_FE == 37 //* The Republicans
replace party_typeH = 4 if countryelection_FE == 37 //* Schill Party
replace party_typeI = . if countryelection_FE == 37

replace vote_partyA = 38.5  if countryelection_FE == 37 
replace vote_partyB = 29.5  if countryelection_FE == 37 
replace vote_partyC =  9.0  if countryelection_FE == 37 
replace vote_partyD =  8.6  if countryelection_FE == 37 
replace vote_partyE =  7.4  if countryelection_FE == 37 
replace vote_partyF =  4.0  if countryelection_FE == 37 
replace vote_partyG =  0.6  if countryelection_FE == 37 
replace vote_partyH =  0.5  if countryelection_FE == 37 
replace vote_partyI =   . if countryelection_FE == 37 

* Germany 2002(2)
replace party_typeA = 1 if countryelection_FE == 38 //* SPD
replace party_typeB = 1 if countryelection_FE == 38 //* CDU
replace party_typeC = 1 if countryelection_FE == 38 //* CSU
replace party_typeD = 1 if countryelection_FE == 38 //* Greens
replace party_typeE = 1 if countryelection_FE == 38 //* FDP
replace party_typeF = 4 if countryelection_FE == 38 //* Left Party
replace party_typeG = 4 if countryelection_FE == 38 //* The Republicans
replace party_typeH = 4 if countryelection_FE == 38 //* Schill Party
replace party_typeI = . if countryelection_FE == 38

replace vote_partyA = 38.5  if countryelection_FE == 38 
replace vote_partyB = 29.5  if countryelection_FE == 38 
replace vote_partyC =  9.0  if countryelection_FE == 38 
replace vote_partyD =  8.6  if countryelection_FE == 38 
replace vote_partyE =  7.4  if countryelection_FE == 38 
replace vote_partyF =  4.0  if countryelection_FE == 38 
replace vote_partyG =  0.6  if countryelection_FE == 38 
replace vote_partyH =  0.5  if countryelection_FE == 38 
replace vote_partyI =   . if countryelection_FE == 38 

* Germany 1998
replace party_typeA = 1 if countryelection_FE == 39 //* SPD
replace party_typeB = 1 if countryelection_FE == 39 //* CDU
replace party_typeC = 1 if countryelection_FE == 39 //* CSU
replace party_typeD = 2 if countryelection_FE == 39 //* Greens
replace party_typeE = 1 if countryelection_FE == 39 //* FDP
replace party_typeF = 4 if countryelection_FE == 39 //* Left Party
replace party_typeG = . if countryelection_FE == 39 
replace party_typeH = . if countryelection_FE == 39
replace party_typeI = . if countryelection_FE == 39

replace vote_partyA = 40.9  if countryelection_FE == 39 
replace vote_partyB = 28.4  if countryelection_FE == 39 
replace vote_partyC =  6.7  if countryelection_FE == 39 
replace vote_partyD =  6.7  if countryelection_FE == 39 
replace vote_partyE =  6.2  if countryelection_FE == 39 
replace vote_partyF =  5.1  if countryelection_FE == 39 
replace vote_partyG =   . if countryelection_FE == 39 
replace vote_partyH =   . if countryelection_FE == 39 
replace vote_partyI =   . if countryelection_FE == 39 

* Germany 2005
replace party_typeA = 1 if countryelection_FE == 40 //* SPD
replace party_typeB = 1 if countryelection_FE == 40 //* CDU
replace party_typeC = 1 if countryelection_FE == 40 //* FDP
replace party_typeD = 4 if countryelection_FE == 40 //* Left
replace party_typeE = 1 if countryelection_FE == 40 //* Greens
replace party_typeF = 1 if countryelection_FE == 40 //* CSU
replace party_typeG = 4 if countryelection_FE == 40 //* NPD
replace party_typeH = . if countryelection_FE == 40
replace party_typeI = . if countryelection_FE == 40

replace vote_partyA = 34.2  if countryelection_FE == 40 
replace vote_partyB = 27.8  if countryelection_FE == 40 
replace vote_partyC =  9.8  if countryelection_FE == 40 
replace vote_partyD =  8.7  if countryelection_FE == 40 
replace vote_partyE =  8.1  if countryelection_FE == 40 
replace vote_partyF =  7.4  if countryelection_FE == 40 
replace vote_partyG =  1.6  if countryelection_FE == 40 
replace vote_partyH =   . if countryelection_FE == 40 
replace vote_partyI =   . if countryelection_FE == 40 

* Germany 2009
replace party_typeA = 1 if countryelection_FE == 41 //* CDU
replace party_typeB = 1 if countryelection_FE == 41 //* SPD
replace party_typeC = 1 if countryelection_FE == 41 //* FDP
replace party_typeD = 4 if countryelection_FE == 41 //* Left
replace party_typeE = 1 if countryelection_FE == 41 //* Greens
replace party_typeF = 1 if countryelection_FE == 41 //* CSU
replace party_typeG = 4 if countryelection_FE == 41 //* NPD
replace party_typeH = . if countryelection_FE == 41
replace party_typeI = . if countryelection_FE == 41

replace vote_partyA = 27.3  if countryelection_FE == 41 
replace vote_partyB = 23.0  if countryelection_FE == 41 
replace vote_partyC = 14.6  if countryelection_FE == 41 
replace vote_partyD = 11.9  if countryelection_FE == 41 
replace vote_partyE = 10.7  if countryelection_FE == 41 
replace vote_partyF =  6.5  if countryelection_FE == 41 
replace vote_partyG =  1.5  if countryelection_FE == 41 
replace vote_partyH =   . if countryelection_FE == 41 
replace vote_partyI =   . if countryelection_FE == 41 

* Germany 2013
replace party_typeA = 1 if countryelection_FE == 42 //* CDU
replace party_typeB = 1 if countryelection_FE == 42 //* SPD
replace party_typeC = 4 if countryelection_FE == 42 //* Left
replace party_typeD = 1 if countryelection_FE == 42 //* Greens
replace party_typeE = 1 if countryelection_FE == 42 //* CSU
replace party_typeF = 1 if countryelection_FE == 42 //* FDP
replace party_typeG = 4 if countryelection_FE == 42 //* AfD
replace party_typeH = 4 if countryelection_FE == 42 //* Pirate Party
replace party_typeI = . if countryelection_FE == 42

replace vote_partyA = 34.1  if countryelection_FE == 42 
replace vote_partyB = 25.7  if countryelection_FE == 42 
replace vote_partyC =  8.6  if countryelection_FE == 42 
replace vote_partyD =  8.4  if countryelection_FE == 42 
replace vote_partyE =  7.4  if countryelection_FE == 42 
replace vote_partyF =  4.8  if countryelection_FE == 42 
replace vote_partyG =  4.7  if countryelection_FE == 42 
replace vote_partyH =  2.2  if countryelection_FE == 42 
replace vote_partyI =   . if countryelection_FE == 42 

* Denmark 98
replace party_typeA = 1 if countryelection_FE == 43 //* SPD
replace party_typeB = 1 if countryelection_FE == 43 //* Liberals
replace party_typeC = 1 if countryelection_FE == 43 //* Cons
replace party_typeD = 1 if countryelection_FE == 43 //* SocPP
replace party_typeE = 4 if countryelection_FE == 43 //* DPP
replace party_typeF = 1 if countryelection_FE == 43 //* CentreDem
replace party_typeG = . if countryelection_FE == 43
replace party_typeH = . if countryelection_FE == 43
replace party_typeI = . if countryelection_FE == 43

replace vote_partyA = 35.9  if countryelection_FE == 43 
replace vote_partyB = 24.0  if countryelection_FE == 43 
replace vote_partyC =  8.9  if countryelection_FE == 43 
replace vote_partyD =  7.6  if countryelection_FE == 43 
replace vote_partyE =  7.4  if countryelection_FE == 43 
replace vote_partyF =  4.3  if countryelection_FE == 43 
replace vote_partyG =   . if countryelection_FE == 43 
replace vote_partyH =   . if countryelection_FE == 43 
replace vote_partyI =   . if countryelection_FE == 43 

* Denmark 01
replace party_typeA = 1 if countryelection_FE == 44 //* Liberals
replace party_typeB = 1 if countryelection_FE == 44 //* SPD
replace party_typeC = 4 if countryelection_FE == 44 //* DanPP
replace party_typeD = 1 if countryelection_FE == 44 //* ConPP
replace party_typeE = 1 if countryelection_FE == 44 //* SocPP
replace party_typeF = 1 if countryelection_FE == 44 //* SocLib
replace party_typeG = 3 if countryelection_FE == 44 //* United Left
replace party_typeH = 1 if countryelection_FE == 44 //* ChristDem
replace party_typeI = 1 if countryelection_FE == 44 //* CentreDem

replace vote_partyA =  31.2 if countryelection_FE == 44 
replace vote_partyB =  29.1 if countryelection_FE == 44 
replace vote_partyC =  12.0 if countryelection_FE == 44 
replace vote_partyD =   9.1 if countryelection_FE == 44 
replace vote_partyE =   6.4 if countryelection_FE == 44 
replace vote_partyF =   5.2 if countryelection_FE == 44 
replace vote_partyG =   2.4 if countryelection_FE == 44 
replace vote_partyH =   2.3 if countryelection_FE == 44 
replace vote_partyI =   1.8 if countryelection_FE == 44 

* Denmark 07
replace party_typeA = 1 if countryelection_FE == 45 //* Liberal Party
replace party_typeB = 1 if countryelection_FE == 45 //* SDP
replace party_typeC = 3 if countryelection_FE == 45 //* Danish PP
replace party_typeD = 1 if countryelection_FE == 45 //* SocPP
replace party_typeE = 1 if countryelection_FE == 45 //* ConsPP
replace party_typeF = 1 if countryelection_FE == 45 //* SocLib
replace party_typeG = 2 if countryelection_FE == 45 //* New Alliance
replace party_typeH = 3 if countryelection_FE == 45 //* United Left
replace party_typeI = 1 if countryelection_FE == 45 //* ChristDem

replace vote_partyA =  26.2 if countryelection_FE == 45 
replace vote_partyB =  25.5 if countryelection_FE == 45 
replace vote_partyC =  13.9 if countryelection_FE == 45 
replace vote_partyD =  13.0 if countryelection_FE == 45 
replace vote_partyE =  10.4 if countryelection_FE == 45 
replace vote_partyF =   5.1 if countryelection_FE == 45 
replace vote_partyG =   2.9 if countryelection_FE == 45 
replace vote_partyH =   2.2 if countryelection_FE == 45 
replace vote_partyI =   0.9 if countryelection_FE == 45 

* Spain 96
replace party_typeA = 1 if countryelection_FE == 46 //* People's Party
replace party_typeB = 1 if countryelection_FE == 46 //* PSOE
replace party_typeC = 4 if countryelection_FE == 46 //* United Left
replace party_typeD = 1 if countryelection_FE == 46 //* Convergence and Union
replace party_typeE = 3 if countryelection_FE == 46 //* BasqueNat
replace party_typeF = 1 if countryelection_FE == 46 //* Canarian Coalition
replace party_typeG = . if countryelection_FE == 46
replace party_typeH = . if countryelection_FE == 46
replace party_typeI = . if countryelection_FE == 46

replace vote_partyA =  38.8 if countryelection_FE == 46 
replace vote_partyB =  37.6 if countryelection_FE == 46 
replace vote_partyC =  10.5 if countryelection_FE == 46 
replace vote_partyD =   4.6 if countryelection_FE == 46 
replace vote_partyE =   1.3 if countryelection_FE == 46 
replace vote_partyF =   0.9 if countryelection_FE == 46 
replace vote_partyG =    . if countryelection_FE == 46 
replace vote_partyH =    . if countryelection_FE == 46 
replace vote_partyI =    . if countryelection_FE == 46 

* Spain 00
replace party_typeA = 1 if countryelection_FE == 47 //* People's Party
replace party_typeB = 1 if countryelection_FE == 47 //* PSOE
replace party_typeC = 3 if countryelection_FE == 47 //* United Left
replace party_typeD = 1 if countryelection_FE == 47 //* Convergence and Union
replace party_typeE = 3 if countryelection_FE == 47 //* BasqueNat
replace party_typeF = . if countryelection_FE == 47
replace party_typeG = . if countryelection_FE == 47
replace party_typeH = . if countryelection_FE == 47
replace party_typeI = . if countryelection_FE == 47

replace vote_partyA = 44.5  if countryelection_FE == 47 
replace vote_partyB = 34.2  if countryelection_FE == 47 
replace vote_partyC =  5.5  if countryelection_FE == 47 
replace vote_partyD =  4.2  if countryelection_FE == 47 
replace vote_partyE =  1.5  if countryelection_FE == 47 
replace vote_partyF =   . if countryelection_FE == 47 
replace vote_partyG =   . if countryelection_FE == 47 
replace vote_partyH =   . if countryelection_FE == 47 
replace vote_partyI =   . if countryelection_FE == 47 

* Spain 04
replace party_typeA = 1 if countryelection_FE == 48 //* PSOE
replace party_typeB = 1 if countryelection_FE == 48 //* People's Party
replace party_typeC = 3 if countryelection_FE == 48 //* United Left
replace party_typeD = 1 if countryelection_FE == 48 //* Convergence and Union
replace party_typeE = 4 if countryelection_FE == 48 //* Rep Left of Catalonia
replace party_typeF = 3 if countryelection_FE == 48 //* BasqueNat
replace party_typeG = 1 if countryelection_FE == 48 //* Canarian Coalition
replace party_typeH = 4 if countryelection_FE == 48 //* Galician Nat Bloc
replace party_typeI = . if countryelection_FE == 48

replace vote_partyA = 42.3  if countryelection_FE == 48 
replace vote_partyB = 37.7  if countryelection_FE == 48 
replace vote_partyC = 5.0   if countryelection_FE == 48 
replace vote_partyD = 3.2   if countryelection_FE == 48 
replace vote_partyE = 2.5   if countryelection_FE == 48 
replace vote_partyF = 1.6   if countryelection_FE == 48 
replace vote_partyG = 0.9   if countryelection_FE == 48 
replace vote_partyH = 0.8   if countryelection_FE == 48 
replace vote_partyI =  .  if countryelection_FE == 48 

* Spain 08
replace party_typeA = 1 if countryelection_FE == 49 //* PSOE
replace party_typeB = 1 if countryelection_FE == 49 //* People's Party
replace party_typeC = 1 if countryelection_FE == 49 //* Convergence and Union
replace party_typeD = 3 if countryelection_FE == 49 //* BasqueNat
replace party_typeE = 3 if countryelection_FE == 49 //* Rep Left of Catalonia
replace party_typeF = 3 if countryelection_FE == 49 //* United Left
replace party_typeG = 3 if countryelection_FE == 49 //* Galician Nat Bloc
replace party_typeH = 1 if countryelection_FE == 49 //* Canarian Coalition
replace party_typeI = 2 if countryelection_FE == 49 //* Union, Progress, and Democracy

replace vote_partyA = 43.9  if countryelection_FE == 49 
replace vote_partyB = 39.9  if countryelection_FE == 49 
replace vote_partyC =  3.0  if countryelection_FE == 49 
replace vote_partyD =  1.2  if countryelection_FE == 49 
replace vote_partyE =  1.2  if countryelection_FE == 49 
replace vote_partyF =  3.8  if countryelection_FE == 49 
replace vote_partyG =  0.8  if countryelection_FE == 49 
replace vote_partyH =  0.7  if countryelection_FE == 49 
replace vote_partyI =  1.2  if countryelection_FE == 49 

* Finland 03
replace party_typeA = 1 if countryelection_FE == 51 //* Centre Party
replace party_typeB = 1 if countryelection_FE == 51 //* Socialists
replace party_typeC = 1 if countryelection_FE == 51 //* KOK
replace party_typeD = 3 if countryelection_FE == 51 //* Left Alliance
replace party_typeE = 1 if countryelection_FE == 51 //* Greens
replace party_typeF = 1 if countryelection_FE == 51 //* ChristDem
replace party_typeG = 1 if countryelection_FE == 51 //* SwedPP
replace party_typeH = . if countryelection_FE == 51
replace party_typeI = . if countryelection_FE == 51

replace vote_partyA = 24.7  if countryelection_FE == 51 
replace vote_partyB = 24.5  if countryelection_FE == 51 
replace vote_partyC = 18.6  if countryelection_FE == 51 
replace vote_partyD =  9.9  if countryelection_FE == 51 
replace vote_partyE =  8.0  if countryelection_FE == 51 
replace vote_partyF =  5.3  if countryelection_FE == 51 
replace vote_partyG =  4.6  if countryelection_FE == 51 
replace vote_partyH =   . if countryelection_FE == 51 
replace vote_partyI =   . if countryelection_FE == 51 

* Finland 07
replace party_typeA = 1 if countryelection_FE == 52 //* Centre Party
replace party_typeB = 1 if countryelection_FE == 52 //* KoK
replace party_typeC = 1 if countryelection_FE == 52 //* SPD
replace party_typeD = 3 if countryelection_FE == 52 //* Left Alliance
replace party_typeE = 1 if countryelection_FE == 52 //* Green Alliance
replace party_typeF = 1 if countryelection_FE == 52 //* SwedPP
replace party_typeG = 1 if countryelection_FE == 52 //* ChristDem
replace party_typeH = 4 if countryelection_FE == 52 //* True Finns
replace party_typeI = . if countryelection_FE == 52

replace vote_partyA = 23.1  if countryelection_FE == 52 
replace vote_partyB = 22.3  if countryelection_FE == 52 
replace vote_partyC = 21.4  if countryelection_FE == 52 
replace vote_partyD =  8.8  if countryelection_FE == 52 
replace vote_partyE =  8.5  if countryelection_FE == 52 
replace vote_partyF =  4.6  if countryelection_FE == 52 
replace vote_partyG =  4.9  if countryelection_FE == 52 
replace vote_partyH =  4.1  if countryelection_FE == 52 
replace vote_partyI =   . if countryelection_FE == 52 

* Finland 11
replace party_typeA = 1 if countryelection_FE == 53 //* KoK
replace party_typeB = 1 if countryelection_FE == 53 //* SPD
replace party_typeC = 4 if countryelection_FE == 53 //* True Finns
replace party_typeD = 1 if countryelection_FE == 53 //* Centre Party
replace party_typeE = 3 if countryelection_FE == 53 //* Left Alliance
replace party_typeF = 1 if countryelection_FE == 53 //* Greens
replace party_typeG = 1 if countryelection_FE == 53 //* SwedPP
replace party_typeH = 1 if countryelection_FE == 53 //* ChristDem
replace party_typeI = . if countryelection_FE == 53

replace vote_partyA = 20.4  if countryelection_FE == 53 
replace vote_partyB = 19.1  if countryelection_FE == 53 
replace vote_partyC = 19.1  if countryelection_FE == 53 
replace vote_partyD = 15.8  if countryelection_FE == 53 
replace vote_partyE =  8.1  if countryelection_FE == 53 
replace vote_partyF =  7.3  if countryelection_FE == 53 
replace vote_partyG =  4.3  if countryelection_FE == 53 
replace vote_partyH =  4.0  if countryelection_FE == 53 
replace vote_partyI =   . if countryelection_FE == 53 

* Finland 15
replace party_typeA = 1 if countryelection_FE == 54 //* CentreParty
replace party_typeB = 1 if countryelection_FE == 54 //* KOK
replace party_typeC = 4 if countryelection_FE == 54 //* True Finns
replace party_typeD = 1 if countryelection_FE == 54 //* SPD
replace party_typeE = 1 if countryelection_FE == 54 //* Greens
replace party_typeF = 3 if countryelection_FE == 54 //* Left
replace party_typeG = 1 if countryelection_FE == 54 //* SwedPP
replace party_typeH = 1 if countryelection_FE == 54 //* ChristDem
replace party_typeI = . if countryelection_FE == 54

replace vote_partyA = 21.1  if countryelection_FE == 54 
replace vote_partyB = 18.2  if countryelection_FE == 54 
replace vote_partyC = 17.7  if countryelection_FE == 54 
replace vote_partyD = 16.5  if countryelection_FE == 54 
replace vote_partyE =  8.5  if countryelection_FE == 54 
replace vote_partyF =  7.1  if countryelection_FE == 54 
replace vote_partyG =  4.9  if countryelection_FE == 54 
replace vote_partyH =  3.5  if countryelection_FE == 54 
replace vote_partyI =   . if countryelection_FE == 54 

* France 07
replace party_typeA = 1 if countryelection_FE == 56 //* UMP
replace party_typeB = 1 if countryelection_FE == 56 //* Socialists
replace party_typeC = 1 if countryelection_FE == 56 //* UDF
replace party_typeD = 4 if countryelection_FE == 56 //* National Front
replace party_typeE = 4 if countryelection_FE == 56 //* Communist
replace party_typeF = 1 if countryelection_FE == 56 //* Greens
replace party_typeG = 4 if countryelection_FE == 56 //* Rev Communist League
replace party_typeH = . if countryelection_FE == 56
replace party_typeI = . if countryelection_FE == 56

replace vote_partyA = 39.5  if countryelection_FE == 56 
replace vote_partyB = 24.7  if countryelection_FE == 56 
replace vote_partyC =  7.6  if countryelection_FE == 56 
replace vote_partyD =  4.3  if countryelection_FE == 56 
replace vote_partyE =  4.3  if countryelection_FE == 56 
replace vote_partyF =  3.3  if countryelection_FE == 56 
replace vote_partyG =  3.4  if countryelection_FE == 56 
replace vote_partyH =   . if countryelection_FE == 56 
replace vote_partyI =   . if countryelection_FE == 56 

* UK 97
replace party_typeA = 1 if countryelection_FE == 58 //* Labour
replace party_typeB = 1 if countryelection_FE == 58 //* Conservatives
replace party_typeC = 1 if countryelection_FE == 58 //* LibDems
replace party_typeD = 4 if countryelection_FE == 58 //* SNP
replace party_typeE = 4 if countryelection_FE == 58 //* PC
replace party_typeF = . if countryelection_FE == 58
replace party_typeG = . if countryelection_FE == 58
replace party_typeH = . if countryelection_FE == 58
replace party_typeI = . if countryelection_FE == 58

replace vote_partyA = 43.2  if countryelection_FE == 58 
replace vote_partyB = 30.7  if countryelection_FE == 58 
replace vote_partyC = 16.8  if countryelection_FE == 58 
replace vote_partyD =  2.0  if countryelection_FE == 58 
replace vote_partyE =  0.5  if countryelection_FE == 58 
replace vote_partyF =   . if countryelection_FE == 58 
replace vote_partyG =   . if countryelection_FE == 58 
replace vote_partyH =   . if countryelection_FE == 58 
replace vote_partyI =   . if countryelection_FE == 58 

* UK 05
replace party_typeA = 1 if countryelection_FE == 59 //* Labour
replace party_typeB = 1 if countryelection_FE == 59 //* Cons
replace party_typeC = 1 if countryelection_FE == 59 //* LibDems
replace party_typeD = 4 if countryelection_FE == 59 //* SNP
replace party_typeE = 4 if countryelection_FE == 59 //* PC
replace party_typeF = . if countryelection_FE == 59
replace party_typeG = . if countryelection_FE == 59
replace party_typeH = . if countryelection_FE == 59
replace party_typeI = . if countryelection_FE == 59

replace vote_partyA = 35.2  if countryelection_FE == 59 
replace vote_partyB = 32.4  if countryelection_FE == 59 
replace vote_partyC = 22.0  if countryelection_FE == 59 
replace vote_partyD =  1.5  if countryelection_FE == 59 
replace vote_partyE =  0.6  if countryelection_FE == 59 
replace vote_partyF =   . if countryelection_FE == 59 
replace vote_partyG =   . if countryelection_FE == 59 
replace vote_partyH =   . if countryelection_FE == 59 
replace vote_partyI =   . if countryelection_FE == 59 

* UK 15
replace party_typeA = 1 if countryelection_FE == 60 //* Cons
replace party_typeB = 1 if countryelection_FE == 60 //* Labour
replace party_typeC = 4 if countryelection_FE == 60 //* UKIP
replace party_typeD = 1 if countryelection_FE == 60 //* LibDems
replace party_typeE = 4 if countryelection_FE == 60 //* SNP
replace party_typeF = 4 if countryelection_FE == 60 //* Greens
replace party_typeG = 4 if countryelection_FE == 60 //* PC
replace party_typeH = . if countryelection_FE == 60
replace party_typeI = . if countryelection_FE == 60

replace vote_partyA = 36.9  if countryelection_FE == 60 
replace vote_partyB = 30.4  if countryelection_FE == 60 
replace vote_partyC = 12.6  if countryelection_FE == 60 
replace vote_partyD =  7.9  if countryelection_FE == 60 
replace vote_partyE =  4.7  if countryelection_FE == 60 
replace vote_partyF =  3.8  if countryelection_FE == 60 
replace vote_partyG =  0.6  if countryelection_FE == 60 
replace vote_partyH =   . if countryelection_FE == 60 
replace vote_partyI =   . if countryelection_FE == 60 

* Greece 09
replace party_typeA = 1 if countryelection_FE == 61 //* PASOK
replace party_typeB = 1 if countryelection_FE == 61 //* New Democracy
replace party_typeC = 4 if countryelection_FE == 61 //* Communists
replace party_typeD = 4 if countryelection_FE == 61 //* Orthodox Rally
replace party_typeE = 4 if countryelection_FE == 61 //* SYRIZA
replace party_typeF = 4 if countryelection_FE == 61 //* Ecologists
replace party_typeG = . if countryelection_FE == 61
replace party_typeH = . if countryelection_FE == 61
replace party_typeI = . if countryelection_FE == 61

replace vote_partyA = 43.9  if countryelection_FE == 61 
replace vote_partyB = 33.5  if countryelection_FE == 61 
replace vote_partyC =  7.5  if countryelection_FE == 61 
replace vote_partyD =  5.6  if countryelection_FE == 61 
replace vote_partyE =  4.6  if countryelection_FE == 61 
replace vote_partyF =  2.5  if countryelection_FE == 61 
replace vote_partyG =   . if countryelection_FE == 61 
replace vote_partyH =   . if countryelection_FE == 61 
replace vote_partyI =   . if countryelection_FE == 61 

* Greece 12
replace party_typeA = 1 if countryelection_FE == 62 //* New Democracy
replace party_typeB = 4 if countryelection_FE == 62 //* SYRIZA
replace party_typeC = 1 if countryelection_FE == 62 //* PASOK
replace party_typeD = 4 if countryelection_FE == 62 //* IndyGreeks
replace party_typeE = 4 if countryelection_FE == 62 //* Golden Dawn
replace party_typeF = 2 if countryelection_FE == 62 //* Democratic Left
replace party_typeG = 4 if countryelection_FE == 62 //* Communist Greece
replace party_typeH = . if countryelection_FE == 62
replace party_typeI = . if countryelection_FE == 62

replace vote_partyA = 18.9  if countryelection_FE == 62 
replace vote_partyB = 16.8  if countryelection_FE == 62 
replace vote_partyC = 13.2  if countryelection_FE == 62 
replace vote_partyD = 10.6  if countryelection_FE == 62 
replace vote_partyE =  7.0  if countryelection_FE == 62 
replace vote_partyF =  6.1  if countryelection_FE == 62 
replace vote_partyG =  8.5  if countryelection_FE == 62 
replace vote_partyH =   . if countryelection_FE == 62 
replace vote_partyI =   . if countryelection_FE == 62 

* Greece 15
replace party_typeA = 4 if countryelection_FE == 63 //* SYRIZA
replace party_typeB = 1 if countryelection_FE == 63 //* NewDem
replace party_typeC = 4 if countryelection_FE == 63 //* Golden Dawn
replace party_typeD = 2 if countryelection_FE == 63 //* The River
replace party_typeE = 4 if countryelection_FE == 63 //* Communist
replace party_typeF = 4 if countryelection_FE == 63 //* Indepedent Greeks
replace party_typeG = 1 if countryelection_FE == 63 //* PASOK
replace party_typeH = . if countryelection_FE == 63
replace party_typeI = . if countryelection_FE == 63

replace vote_partyA = 36.3  if countryelection_FE == 63 
replace vote_partyB = 27.8  if countryelection_FE == 63 
replace vote_partyC =  6.3  if countryelection_FE == 63 
replace vote_partyD =  6.1  if countryelection_FE == 63 
replace vote_partyE =  5.5  if countryelection_FE == 63 
replace vote_partyF =  4.8  if countryelection_FE == 63 
replace vote_partyG =  4.7  if countryelection_FE == 63 
replace vote_partyH =   . if countryelection_FE == 63 
replace vote_partyI =   . if countryelection_FE == 63 

* Ireland 02
replace party_typeA = 1 if countryelection_FE == 72 //* Fianna Fail
replace party_typeB = 1 if countryelection_FE == 72 //* Fine Gael
replace party_typeC = 1 if countryelection_FE == 72 //* Labour
replace party_typeD = 4 if countryelection_FE == 72 //* Sinn Fein
replace party_typeE = 1 if countryelection_FE == 72 //* ProgDem
replace party_typeF = 4 if countryelection_FE == 72 //* Greens
replace party_typeG = . if countryelection_FE == 72
replace party_typeH = . if countryelection_FE == 72
replace party_typeI = . if countryelection_FE == 72

replace vote_partyA = 41.5  if countryelection_FE == 72 
replace vote_partyB = 22.5  if countryelection_FE == 72 
replace vote_partyC = 10.8  if countryelection_FE == 72 
replace vote_partyD =  6.5  if countryelection_FE == 72 
replace vote_partyE =  4.0  if countryelection_FE == 72 
replace vote_partyF =  3.8  if countryelection_FE == 72 
replace vote_partyG =   . if countryelection_FE == 72 
replace vote_partyH =   . if countryelection_FE == 72 
replace vote_partyI =   . if countryelection_FE == 72 

* Ireland 07
replace party_typeA = 1 if countryelection_FE == 73 //* Fianna Fail
replace party_typeB = 1 if countryelection_FE == 73 //* Fine Gael
replace party_typeC = 1 if countryelection_FE == 73 //* Labour
replace party_typeD = 2 if countryelection_FE == 73 //* Greens
replace party_typeE = 4 if countryelection_FE == 73 //* Sinn Fein
replace party_typeF = 1 if countryelection_FE == 73 //* ProgDem
replace party_typeG = . if countryelection_FE == 73
replace party_typeH = . if countryelection_FE == 73
replace party_typeI = . if countryelection_FE == 73

replace vote_partyA = 41.6  if countryelection_FE == 73 
replace vote_partyB = 27.3  if countryelection_FE == 73 
replace vote_partyC = 10.1  if countryelection_FE == 73 
replace vote_partyD =  4.7  if countryelection_FE == 73 
replace vote_partyE =  6.9  if countryelection_FE == 73 
replace vote_partyF =  2.7  if countryelection_FE == 73 
replace vote_partyG =   . if countryelection_FE == 73 
replace vote_partyH =   . if countryelection_FE == 73 
replace vote_partyI =   . if countryelection_FE == 73 

* Ireland 11
replace party_typeA = 1 if countryelection_FE == 74 //* Fine Gael
replace party_typeB = 1 if countryelection_FE == 74 //* Labour
replace party_typeC = 1 if countryelection_FE == 74 //* Fianna Fail
replace party_typeD = 4 if countryelection_FE == 74 //* Sinn Fein
replace party_typeE = 4 if countryelection_FE == 74 //* United Left Alliance
replace party_typeF = 1 if countryelection_FE == 74 //* Greens
replace party_typeG = . if countryelection_FE == 74
replace party_typeH = . if countryelection_FE == 74
replace party_typeI = . if countryelection_FE == 74

replace vote_partyA = 36.1  if countryelection_FE == 74 
replace vote_partyB = 19.5  if countryelection_FE == 74 
replace vote_partyC = 17.5  if countryelection_FE == 74 
replace vote_partyD =  9.9  if countryelection_FE == 74 
replace vote_partyE =  1.2  if countryelection_FE == 74 
replace vote_partyF =  1.9  if countryelection_FE == 74 
replace vote_partyG =   . if countryelection_FE == 74 
replace vote_partyH =   . if countryelection_FE == 74 
replace vote_partyI =   . if countryelection_FE == 74 

* Iceland 99
replace party_typeA = 1 if countryelection_FE == 75 //* Independence
replace party_typeB = 1 if countryelection_FE == 75 //* SDA
replace party_typeC = 1 if countryelection_FE == 75 //* Progressive
replace party_typeD = 4 if countryelection_FE == 75 //* Left-Green Alliance
replace party_typeE = 2 if countryelection_FE == 75 //* Liberals
replace party_typeF = . if countryelection_FE == 75
replace party_typeG = . if countryelection_FE == 75
replace party_typeH = . if countryelection_FE == 75
replace party_typeI = . if countryelection_FE == 75

replace vote_partyA = 40.7  if countryelection_FE == 75 
replace vote_partyB = 26.8  if countryelection_FE == 75 
replace vote_partyC = 18.4  if countryelection_FE == 75 
replace vote_partyD =  9.1  if countryelection_FE == 75 
replace vote_partyE =  4.2  if countryelection_FE == 75 
replace vote_partyF =   . if countryelection_FE == 75 
replace vote_partyG =   . if countryelection_FE == 75 
replace vote_partyH =   . if countryelection_FE == 75 
replace vote_partyI =   . if countryelection_FE == 75 

* Iceland 03
replace party_typeA = 1 if countryelection_FE == 76 //* Independence
replace party_typeB = 1 if countryelection_FE == 76 //* SDA
replace party_typeC = 1 if countryelection_FE == 76 //* Progressive
replace party_typeD = 4 if countryelection_FE == 76 //* Left-Green
replace party_typeE = 2 if countryelection_FE == 76 //* Liberals
replace party_typeF = . if countryelection_FE == 76
replace party_typeG = . if countryelection_FE == 76
replace party_typeH = . if countryelection_FE == 76
replace party_typeI = . if countryelection_FE == 76

replace vote_partyA = 33.7  if countryelection_FE == 76 
replace vote_partyB = 31.0  if countryelection_FE == 76 
replace vote_partyC = 17.7  if countryelection_FE == 76 
replace vote_partyD =  8.8  if countryelection_FE == 76 
replace vote_partyE =  7.4  if countryelection_FE == 76 
replace vote_partyF =   . if countryelection_FE == 76 
replace vote_partyG =   . if countryelection_FE == 76 
replace vote_partyH =   . if countryelection_FE == 76 
replace vote_partyI =   . if countryelection_FE == 76 

* Iceland 07
replace party_typeA = 1 if countryelection_FE == 77 //* Independence
replace party_typeB = 1 if countryelection_FE == 77 //* SDA
replace party_typeC = 4 if countryelection_FE == 77 //* Left-Green
replace party_typeD = 1 if countryelection_FE == 77 //* Progressive
replace party_typeE = 4 if countryelection_FE == 77 //* Liberal
replace party_typeF = 2 if countryelection_FE == 77 //* Icelandic Movement
replace party_typeG = . if countryelection_FE == 77
replace party_typeH = . if countryelection_FE == 77
replace party_typeI = . if countryelection_FE == 77

replace vote_partyA = 36.6  if countryelection_FE == 77 
replace vote_partyB = 26.8  if countryelection_FE == 77 
replace vote_partyC = 14.3  if countryelection_FE == 77 
replace vote_partyD = 11.7  if countryelection_FE == 77 
replace vote_partyE =  7.3  if countryelection_FE == 77 
replace vote_partyF =  3.3  if countryelection_FE == 77 
replace vote_partyG =   . if countryelection_FE == 77 
replace vote_partyH =   . if countryelection_FE == 77 
replace vote_partyI =   . if countryelection_FE == 77 

* Iceland 09
replace party_typeA = 1 if countryelection_FE == 78 //* SDA
replace party_typeB = 1 if countryelection_FE == 78 //* Independence
replace party_typeC = 4 if countryelection_FE == 78 //* Left-Green
replace party_typeD = 1 if countryelection_FE == 78 //* ProgDem
replace party_typeE = 4 if countryelection_FE == 78 //* Civic Movement
replace party_typeF = 4 if countryelection_FE == 78 //* Liberal
replace party_typeG = . if countryelection_FE == 78
replace party_typeH = . if countryelection_FE == 78
replace party_typeI = . if countryelection_FE == 78

replace vote_partyA = 29.8 if countryelection_FE == 78 
replace vote_partyB = 23.7 if countryelection_FE == 78 
replace vote_partyC = 21.7 if countryelection_FE == 78 
replace vote_partyD = 14.8 if countryelection_FE == 78 
replace vote_partyE =  7.2 if countryelection_FE == 78 
replace vote_partyF =  2.2 if countryelection_FE == 78 
replace vote_partyG =   . if countryelection_FE == 78 
replace vote_partyH =   . if countryelection_FE == 78 
replace vote_partyI =   . if countryelection_FE == 78 

* Iceland 13
replace party_typeA = 1 if countryelection_FE == 79 //* Independence Party
replace party_typeB = 1 if countryelection_FE == 79 //* Progressive 
replace party_typeC = 1 if countryelection_FE == 79 //* SDA
replace party_typeD = 3 if countryelection_FE == 79 //* Left Green Movement
replace party_typeE = 4 if countryelection_FE == 79 //* Bright Future
replace party_typeF = 4 if countryelection_FE == 79 //* Pirates
replace party_typeG = . if countryelection_FE == 79
replace party_typeH = . if countryelection_FE == 79
replace party_typeI = . if countryelection_FE == 79

replace vote_partyA =  26.7 if countryelection_FE == 79 
replace vote_partyB =  24.4 if countryelection_FE == 79 
replace vote_partyC =  12.9 if countryelection_FE == 79 
replace vote_partyD =  10.9 if countryelection_FE == 79 
replace vote_partyE =   8.2 if countryelection_FE == 79 
replace vote_partyF =   5.1 if countryelection_FE == 79 
replace vote_partyG =    . if countryelection_FE == 79 
replace vote_partyH =    . if countryelection_FE == 79 
replace vote_partyI =    . if countryelection_FE == 79 

* Italy 06
replace party_typeA = 1 if countryelection_FE == 84 //* Forza Italia
replace party_typeB = 1 if countryelection_FE == 84 //* Democrats
replace party_typeC = 3 if countryelection_FE == 84 //* National Alliance
replace party_typeD = 1 if countryelection_FE == 84 //* The Daisy
replace party_typeE = 1 if countryelection_FE == 84 //* Centre Union
replace party_typeF = 3 if countryelection_FE == 84 //* Communists
replace party_typeG = . if countryelection_FE == 84
replace party_typeH = . if countryelection_FE == 84
replace party_typeI = . if countryelection_FE == 84

replace vote_partyA = 23.7  if countryelection_FE == 84 
replace vote_partyB = 25.3  if countryelection_FE == 84 
replace vote_partyC = 12.3  if countryelection_FE == 84 
replace vote_partyD =  6.0  if countryelection_FE == 84 
replace vote_partyE =  6.8  if countryelection_FE == 84 
replace vote_partyF =  5.8  if countryelection_FE == 84 
replace vote_partyG =   .  if countryelection_FE == 84 
replace vote_partyH =   . if countryelection_FE == 84 
replace vote_partyI =   . if countryelection_FE == 84 

* Netherlands 98
replace party_typeA = 1 if countryelection_FE == 107 //* Labour Party
replace party_typeB = 1 if countryelection_FE == 107 //* PPFD
replace party_typeC = 1 if countryelection_FE == 107 //* Christ Dem Appeal
replace party_typeD = 3 if countryelection_FE == 107 //* D66
replace party_typeE = 4 if countryelection_FE == 107 //* GreenLeft
replace party_typeF = 4 if countryelection_FE == 107 //* SocialistParty
replace party_typeG = 4 if countryelection_FE == 107 //* Reformed Alliance
replace party_typeH = . if countryelection_FE == 107
replace party_typeI = . if countryelection_FE == 107

replace vote_partyA = 21.2  if countryelection_FE == 107 
replace vote_partyB = 14.7  if countryelection_FE == 107 
replace vote_partyC = 26.5  if countryelection_FE == 107 
replace vote_partyD =  2.0  if countryelection_FE == 107 
replace vote_partyE =  4.6  if countryelection_FE == 107 
replace vote_partyF = 16.6  if countryelection_FE == 107 
replace vote_partyG =  1.6  if countryelection_FE == 107 
replace vote_partyH =   . if countryelection_FE == 107 
replace vote_partyI =   . if countryelection_FE == 107 

* Netherlands 02
replace party_typeA = 1 if countryelection_FE == 108 //* CDA
replace party_typeB = 4 if countryelection_FE == 108 //* Pim Fortuyn List
replace party_typeC = 1 if countryelection_FE == 108 //* PPFD
replace party_typeD = 1 if countryelection_FE == 108 //* Labor Party
replace party_typeE = 4 if countryelection_FE == 108 //* GreenLeft
replace party_typeF = 4 if countryelection_FE == 108 //* Socialist Party
replace party_typeG = 3 if countryelection_FE == 108 //* D66
replace party_typeH = 2 if countryelection_FE == 108 //* Christian Union
replace party_typeI = 4 if countryelection_FE == 108 //* Reformed Party

replace vote_partyA = 27.9  if countryelection_FE == 108 
replace vote_partyB = 17.0  if countryelection_FE == 108 
replace vote_partyC = 15.4  if countryelection_FE == 108 
replace vote_partyD = 15.1  if countryelection_FE == 108 
replace vote_partyE =  7.0  if countryelection_FE == 108 
replace vote_partyF =  5.9  if countryelection_FE == 108 
replace vote_partyG =  5.1  if countryelection_FE == 108 
replace vote_partyH =  2.5  if countryelection_FE == 108 
replace vote_partyI =  1.7  if countryelection_FE == 108 

* Netherlands 06
replace party_typeA = 1 if countryelection_FE == 109 //* CDA
replace party_typeB = 1 if countryelection_FE == 109 //* Labor Party
replace party_typeC = 4 if countryelection_FE == 109 //* Socialist Party
replace party_typeD = 1 if countryelection_FE == 109 //* PPFD
replace party_typeE = 4 if countryelection_FE == 109 //* Party for Freedom
replace party_typeF = 2 if countryelection_FE == 109 //* GreenLeft
replace party_typeG = 2 if countryelection_FE == 109 //* Christian Union
replace party_typeH = 3 if countryelection_FE == 109 //* D66
replace party_typeI = 4 if countryelection_FE == 109 //* Reformed Party

replace vote_partyA = 26.5  if countryelection_FE == 109 
replace vote_partyB = 21.2  if countryelection_FE == 109 
replace vote_partyC = 16.6  if countryelection_FE == 109 
replace vote_partyD = 14.7  if countryelection_FE == 109 
replace vote_partyE =  5.9  if countryelection_FE == 109 
replace vote_partyF =  4.6  if countryelection_FE == 109 
replace vote_partyG =  4.0  if countryelection_FE == 109 
replace vote_partyH =  2.0  if countryelection_FE == 109 
replace vote_partyI =  1.6  if countryelection_FE == 109 

* Netherlands 10
replace party_typeA = 1 if countryelection_FE == 110 //* PPFD
replace party_typeB = 1 if countryelection_FE == 110 //* Labor Party
replace party_typeC = 4 if countryelection_FE == 110 //* Party for Freedom
replace party_typeD = 1 if countryelection_FE == 110 //* CDA
replace party_typeE = 4 if countryelection_FE == 110 //* Socialist Party
replace party_typeF = 3 if countryelection_FE == 110 //* D66
replace party_typeG = 2 if countryelection_FE == 110 //* GreenLeft
replace party_typeH = 1 if countryelection_FE == 110 //* Christian Union
replace party_typeI = 4 if countryelection_FE == 110 //* Reformed Party

replace vote_partyA = 20.5  if countryelection_FE == 110 
replace vote_partyB = 19.6  if countryelection_FE == 110 
replace vote_partyC = 15.5  if countryelection_FE == 110 
replace vote_partyD = 13.6  if countryelection_FE == 110 
replace vote_partyE =  9.8  if countryelection_FE == 110 
replace vote_partyF =  7.0  if countryelection_FE == 110 
replace vote_partyG =  6.7  if countryelection_FE == 110 
replace vote_partyH =  3.2  if countryelection_FE == 110 
replace vote_partyI =  1.7  if countryelection_FE == 110 

* Norway 97
replace party_typeA = 1 if countryelection_FE == 111 //* Labour Party
replace party_typeB = 4 if countryelection_FE == 111 //* Progress Party
replace party_typeC = 1 if countryelection_FE == 111 //* Conservative Party
replace party_typeD = 1 if countryelection_FE == 111 //* Christian People's
replace party_typeE = 1 if countryelection_FE == 111 //* Centre Party
replace party_typeF = 4 if countryelection_FE == 111 //* Socialist Left Party
replace party_typeG = . if countryelection_FE == 111
replace party_typeH = . if countryelection_FE == 111
replace party_typeI = . if countryelection_FE == 111

replace vote_partyA =  35.0 if countryelection_FE == 111 
replace vote_partyB =  15.3 if countryelection_FE == 111 
replace vote_partyC =  14.3 if countryelection_FE == 111 
replace vote_partyD =  13.7 if countryelection_FE == 111 
replace vote_partyE =   7.9 if countryelection_FE == 111 
replace vote_partyF =   6.0 if countryelection_FE == 111 
replace vote_partyG =    . if countryelection_FE == 111 
replace vote_partyH =    . if countryelection_FE == 111 
replace vote_partyI =    . if countryelection_FE == 111 

* Norway 01
replace party_typeA = 1 if countryelection_FE == 112 //* Labour
replace party_typeB = 1 if countryelection_FE == 112 //* Conservatives
replace party_typeC = 4 if countryelection_FE == 112 //* Progress
replace party_typeD = 2 if countryelection_FE == 112 //* Socialist Left
replace party_typeE = 1 if countryelection_FE == 112 //* Christian People's
replace party_typeF = 1 if countryelection_FE == 112 //* Centre Party
replace party_typeG = 1 if countryelection_FE == 112 //* Liberal Party
replace party_typeH = . if countryelection_FE == 112
replace party_typeI = . if countryelection_FE == 112

replace vote_partyA = 24.3  if countryelection_FE == 112 
replace vote_partyB = 21.2  if countryelection_FE == 112 
replace vote_partyC = 14.6  if countryelection_FE == 112 
replace vote_partyD = 12.5  if countryelection_FE == 112 
replace vote_partyE = 12.4  if countryelection_FE == 112 
replace vote_partyF =  5.6  if countryelection_FE == 112 
replace vote_partyG =  3.9  if countryelection_FE == 112 
replace vote_partyH =   . if countryelection_FE == 112 
replace vote_partyI =   . if countryelection_FE == 112 

* Norway 05
replace party_typeA = 1 if countryelection_FE == 113 //* Labour
replace party_typeB = 3 if countryelection_FE == 113 //* Progress
replace party_typeC = 1 if countryelection_FE == 113 //* Conservative Party
replace party_typeD = 4 if countryelection_FE == 113 //* Socialist Left
replace party_typeE = 1 if countryelection_FE == 113 //* Christian People's
replace party_typeF = 1 if countryelection_FE == 113 //* Centre Party
replace party_typeG = 1 if countryelection_FE == 113 //* Liberal Party
replace party_typeH = 4 if countryelection_FE == 113 //* Red Alliance
replace party_typeI = . if countryelection_FE == 113

replace vote_partyA = 32.7  if countryelection_FE == 113 
replace vote_partyB = 22.1  if countryelection_FE == 113 
replace vote_partyC = 14.1  if countryelection_FE == 113 
replace vote_partyD =  8.8  if countryelection_FE == 113 
replace vote_partyE =  6.8  if countryelection_FE == 113 
replace vote_partyF =  6.5  if countryelection_FE == 113 
replace vote_partyG =  5.9  if countryelection_FE == 113 
replace vote_partyH =  1.2  if countryelection_FE == 113 
replace vote_partyI =   . if countryelection_FE == 113 

* Norway 09
replace party_typeA = 1 if countryelection_FE == 114 //* Labour
replace party_typeB = 1 if countryelection_FE == 114 //* Progress
replace party_typeC = 1 if countryelection_FE == 114 //* Conservative Party
replace party_typeD = 1 if countryelection_FE == 114 //* SocialistLeft
replace party_typeE = 1 if countryelection_FE == 114 //* Centre
replace party_typeF = 1 if countryelection_FE == 114 //* Christian People's
replace party_typeG = 1 if countryelection_FE == 114 //* Liberals
replace party_typeH = 4 if countryelection_FE == 114 //* Red Alliance
replace party_typeI = . if countryelection_FE == 114

replace vote_partyA = 35.4 if countryelection_FE == 114 
replace vote_partyB = 22.9 if countryelection_FE == 114 
replace vote_partyC = 17.2 if countryelection_FE == 114 
replace vote_partyD =  6.2 if countryelection_FE == 114 
replace vote_partyE =  6.2 if countryelection_FE == 114 
replace vote_partyF =  5.5 if countryelection_FE == 114 
replace vote_partyG =  3.9 if countryelection_FE == 114 
replace vote_partyH =  1.3 if countryelection_FE == 114 
replace vote_partyI =   .  if countryelection_FE == 114 

* Norway 13
replace party_typeA = 1 if countryelection_FE == 115 //* Labour
replace party_typeB = 1 if countryelection_FE == 115 //* Conservative
replace party_typeC = 1 if countryelection_FE == 115 //* Progress
replace party_typeD = 1 if countryelection_FE == 115 //* Christian People's
replace party_typeE = 1 if countryelection_FE == 115 //* Centre Party
replace party_typeF = 1 if countryelection_FE == 115 //* Liberal
replace party_typeG = 1 if countryelection_FE == 115 //* Socialist Left
replace party_typeH = 4 if countryelection_FE == 115 //* Greens
replace party_typeI = 4 if countryelection_FE == 115 //* Red Party

replace vote_partyA = 30.8  if countryelection_FE == 115 
replace vote_partyB = 26.8  if countryelection_FE == 115 
replace vote_partyC = 16.3  if countryelection_FE == 115 
replace vote_partyD =  5.6  if countryelection_FE == 115 
replace vote_partyE =  5.5  if countryelection_FE == 115 
replace vote_partyF =  5.2  if countryelection_FE == 115 
replace vote_partyG =  4.1  if countryelection_FE == 115 
replace vote_partyH =  2.8  if countryelection_FE == 115 
replace vote_partyI =  1.1  if countryelection_FE == 115 

* NZ 96
replace party_typeA = 1 if countryelection_FE == 116 //* National Party
replace party_typeB = 1 if countryelection_FE == 116 //* Labour
replace party_typeC = 4 if countryelection_FE == 116 //* NZ First
replace party_typeD = 2 if countryelection_FE == 116 //* Alliance
replace party_typeE = 4 if countryelection_FE == 116 //* ACT
replace party_typeF = 1 if countryelection_FE == 116 //* Christian Coalition
replace party_typeG = . if countryelection_FE == 116
replace party_typeH = . if countryelection_FE == 116
replace party_typeI = . if countryelection_FE == 116

replace vote_partyA = 33.8  if countryelection_FE == 116 
replace vote_partyB = 28.2  if countryelection_FE == 116 
replace vote_partyC = 13.3  if countryelection_FE == 116 
replace vote_partyD =  8.1  if countryelection_FE == 116 
replace vote_partyE =  6.1  if countryelection_FE == 116 
replace vote_partyF =  4.3  if countryelection_FE == 116 
replace vote_partyG =   . if countryelection_FE == 116 
replace vote_partyH =   . if countryelection_FE == 116 
replace vote_partyI =   . if countryelection_FE == 116 

* NZ 02
replace party_typeA = 1 if countryelection_FE == 117 //* Labour
replace party_typeB = 1 if countryelection_FE == 117 //* National
replace party_typeC = 3 if countryelection_FE == 117 //* NZ First
replace party_typeD = 4 if countryelection_FE == 117 //* ACT
replace party_typeE = 1 if countryelection_FE == 117 //* Greens
replace party_typeF = 2 if countryelection_FE == 117 //* United Future NZ
replace party_typeG = 1 if countryelection_FE == 117 //* Anderton Progressive
replace party_typeH = 1 if countryelection_FE == 117 //* Alliance
replace party_typeI = . if countryelection_FE == 117

replace vote_partyA = 41.3  if countryelection_FE == 117 
replace vote_partyB = 20.9  if countryelection_FE == 117 
replace vote_partyC = 10.4  if countryelection_FE == 117 
replace vote_partyD =  7.1  if countryelection_FE == 117 
replace vote_partyE =  7.0  if countryelection_FE == 117 
replace vote_partyF =  6.7  if countryelection_FE == 117 
replace vote_partyG =  1.7  if countryelection_FE == 117 
replace vote_partyH =  1.3  if countryelection_FE == 117 
replace vote_partyI =   . if countryelection_FE == 117 

* NZ 08 (NA)
replace party_typeA = 1 if countryelection_FE == 118 //* National
replace party_typeB = 1 if countryelection_FE == 118 //* Labour
replace party_typeC = 1 if countryelection_FE == 118 //* Greens
replace party_typeD = 3 if countryelection_FE == 118 //* NZ First
replace party_typeE = 1 if countryelection_FE == 118 //* ACT NZ
replace party_typeF = 1 if countryelection_FE == 118 //* Maori Party
replace party_typeG = 1 if countryelection_FE == 118 //* Anderton Prog
replace party_typeH = 1 if countryelection_FE == 118 //* United NZ
replace party_typeI = . if countryelection_FE == 118 //* 

replace vote_partyA = 44.9  if countryelection_FE == 118 
replace vote_partyB = 34.0  if countryelection_FE == 118 
replace vote_partyC =  6.7  if countryelection_FE == 118 
replace vote_partyD =  4.1  if countryelection_FE == 118 
replace vote_partyE =  3.7  if countryelection_FE == 118 
replace vote_partyF =  2.4  if countryelection_FE == 118 
replace vote_partyG =  0.9  if countryelection_FE == 118 
replace vote_partyH =  0.9  if countryelection_FE == 118 
replace vote_partyI =  .  if countryelection_FE == 118 

* NZ 11
replace party_typeA = 1 if countryelection_FE == 119 //* National
replace party_typeB = 1 if countryelection_FE == 119 //* Labour
replace party_typeC = 1 if countryelection_FE == 119 //* Greens
replace party_typeD = 3 if countryelection_FE == 119 //* NZ First
replace party_typeE = 4 if countryelection_FE == 119 //* Conservative Party
replace party_typeF = 1 if countryelection_FE == 119 //* Maori Party
replace party_typeG = 4 if countryelection_FE == 119 //* MANA Movement
replace party_typeH = 3 if countryelection_FE == 119 //* ACT
replace party_typeI = 1 if countryelection_FE == 119 //* United NZ

replace vote_partyA = 47.3  if countryelection_FE == 119 
replace vote_partyB = 27.5  if countryelection_FE == 119 
replace vote_partyC = 11.1  if countryelection_FE == 119 
replace vote_partyD =  6.6  if countryelection_FE == 119 
replace vote_partyE =  2.7  if countryelection_FE == 119 
replace vote_partyF =  1.4  if countryelection_FE == 119 
replace vote_partyG =  1.1  if countryelection_FE == 119 
replace vote_partyH =  1.1  if countryelection_FE == 119 
replace vote_partyI =  0.6  if countryelection_FE == 119 

* NZ 14
replace party_typeA = 1 if countryelection_FE == 120 //* National Party
replace party_typeB = 1 if countryelection_FE == 120 //* Labour
replace party_typeC = 1 if countryelection_FE == 120 //* Greens
replace party_typeD = 3 if countryelection_FE == 120 //* NZ First
replace party_typeE = 4 if countryelection_FE == 120 //* Conservative
replace party_typeF = 4 if countryelection_FE == 120 //* MANA
replace party_typeG = 1 if countryelection_FE == 120 //* Maori
replace party_typeH = 3 if countryelection_FE == 120 //* ACT
replace party_typeI = 1 if countryelection_FE == 120 //* United NZ

replace vote_partyA = 47.0  if countryelection_FE == 120 
replace vote_partyB = 25.1  if countryelection_FE == 120 
replace vote_partyC = 10.7  if countryelection_FE == 120 
replace vote_partyD =  8.7  if countryelection_FE == 120 
replace vote_partyE =  4.0  if countryelection_FE == 120 
replace vote_partyF =  1.4  if countryelection_FE == 120 
replace vote_partyG =  1.3  if countryelection_FE == 120 
replace vote_partyH =  0.7  if countryelection_FE == 120 
replace vote_partyI =  0.2  if countryelection_FE == 120 

* Portugal 02
replace party_typeA = 1 if countryelection_FE == 134 //* SDP
replace party_typeB = 1 if countryelection_FE == 134 //* Socialist
replace party_typeC = 1 if countryelection_FE == 134 //* Popular
replace party_typeD = 4 if countryelection_FE == 134 //* PRT Coalition
replace party_typeE = 4 if countryelection_FE == 134 //* Left Bloc
replace party_typeF = 4 if countryelection_FE == 134 //* Workers' Com
replace party_typeG = . if countryelection_FE == 134
replace party_typeH = . if countryelection_FE == 134
replace party_typeI = . if countryelection_FE == 134

replace vote_partyA = 41.0  if countryelection_FE == 134 
replace vote_partyB = 38.6  if countryelection_FE == 134 
replace vote_partyC =  8.9  if countryelection_FE == 134 
replace vote_partyD =  7.1  if countryelection_FE == 134 
replace vote_partyE =  2.9  if countryelection_FE == 134 
replace vote_partyF =  0.7  if countryelection_FE == 134 
replace vote_partyG =   . if countryelection_FE == 134 
replace vote_partyH =   . if countryelection_FE == 134 
replace vote_partyI =   . if countryelection_FE == 134 

* Portugal 05
replace party_typeA = 1 if countryelection_FE == 135 //* Socialist
replace party_typeB = 1 if countryelection_FE == 135 //* SDP
replace party_typeC = 4 if countryelection_FE == 135 //* PRT Coalition
replace party_typeD = 1 if countryelection_FE == 135 //* Popular Party
replace party_typeE = 4 if countryelection_FE == 135 //* Left Bloc
replace party_typeF = 4 if countryelection_FE == 135 //* Communist Party
replace party_typeG = 4 if countryelection_FE == 135 //* Greens
replace party_typeH = . if countryelection_FE == 135
replace party_typeI = . if countryelection_FE == 135

replace vote_partyA = 46.4  if countryelection_FE == 135 
replace vote_partyB = 29.6  if countryelection_FE == 135 
replace vote_partyC =  6.7  if countryelection_FE == 135 
replace vote_partyD =  7.5  if countryelection_FE == 135 
replace vote_partyE =  6.5  if countryelection_FE == 135 
replace vote_partyF =  0.9  if countryelection_FE == 135 
replace vote_partyG =  1.1 if countryelection_FE == 135 
replace vote_partyH =   . if countryelection_FE == 135 
replace vote_partyI =   . if countryelection_FE == 135 

* Portugal 09
replace party_typeA = 1 if countryelection_FE == 136 //* Socialist
replace party_typeB = 1 if countryelection_FE == 136 //* SDP
replace party_typeC = 1 if countryelection_FE == 136 //* Popular Party
replace party_typeD = 4 if countryelection_FE == 136 //* Left Bloc
replace party_typeE = 4 if countryelection_FE == 136 //* PRT Coalition
replace party_typeF = . if countryelection_FE == 136
replace party_typeG = . if countryelection_FE == 136
replace party_typeH = . if countryelection_FE == 136
replace party_typeI = . if countryelection_FE == 136

replace vote_partyA = 37.7  if countryelection_FE == 136 
replace vote_partyB = 30.0  if countryelection_FE == 136 
replace vote_partyC = 10.7  if countryelection_FE == 136 
replace vote_partyD = 10.1  if countryelection_FE == 136 
replace vote_partyE =  8.1  if countryelection_FE == 136 
replace vote_partyF =   . if countryelection_FE == 136 
replace vote_partyG =   . if countryelection_FE == 136 
replace vote_partyH =   . if countryelection_FE == 136 
replace vote_partyI =   . if countryelection_FE == 136 

* Portugal 15
replace party_typeA = 1 if countryelection_FE == 137 //* Portugal Ahead
replace party_typeB = 1 if countryelection_FE == 137 //* Socialist Party
replace party_typeC = 4 if countryelection_FE == 137 //* Left Bloc
replace party_typeD = 4 if countryelection_FE == 137 //* PRT - Coalition
replace party_typeE = 2 if countryelection_FE == 137 //* NATURE Party
replace party_typeF = 2 if countryelection_FE == 137 //* Democratic Republican
replace party_typeG = 4 if countryelection_FE == 137 //* Workers' Com
replace party_typeH = 1 if countryelection_FE == 137 //* Popular Party
replace party_typeI = . if countryelection_FE == 137

replace vote_partyA = 30.4  if countryelection_FE == 137 
replace vote_partyB = 33.6  if countryelection_FE == 137 
replace vote_partyC = 10.6  if countryelection_FE == 137 
replace vote_partyD =  8.6  if countryelection_FE == 137 
replace vote_partyE =  1.4  if countryelection_FE == 137 
replace vote_partyF =  1.2  if countryelection_FE == 137 
replace vote_partyG =  1.2  if countryelection_FE == 137 
replace vote_partyH =  6.5  if countryelection_FE == 137 
replace vote_partyI =   .   if countryelection_FE == 137 

* Sweden 98
replace party_typeA = 1 if countryelection_FE == 153 //* SPD
replace party_typeB = 1 if countryelection_FE == 153 //* Moderate
replace party_typeC = 4 if countryelection_FE == 153 //* Left Party
replace party_typeD = 1 if countryelection_FE == 153 //* ChristDem
replace party_typeE = 1 if countryelection_FE == 153 //* Centre Party
replace party_typeF = 1 if countryelection_FE == 153 //* Lib People's
replace party_typeG = . if countryelection_FE == 153
replace party_typeH = . if countryelection_FE == 153
replace party_typeI = . if countryelection_FE == 153

replace vote_partyA = 36.4  if countryelection_FE == 153 
replace vote_partyB = 22.9  if countryelection_FE == 153 
replace vote_partyC = 12.0  if countryelection_FE == 153 
replace vote_partyD = 11.8  if countryelection_FE == 153 
replace vote_partyE =  5.1  if countryelection_FE == 153 
replace vote_partyF =  4.7  if countryelection_FE == 153 
replace vote_partyG =   . if countryelection_FE == 153 
replace vote_partyH =   . if countryelection_FE == 153 
replace vote_partyI =   . if countryelection_FE == 153 

* Sweden 02 (NA)
replace party_typeA = 1 if countryelection_FE == 154 //* SPD
replace party_typeB = 1 if countryelection_FE == 154 //* Moderate
replace party_typeC = 1 if countryelection_FE == 154 //* Liberal People's
replace party_typeD = 1 if countryelection_FE == 154 //* Christian Democrats
replace party_typeE = 4 if countryelection_FE == 154 //* Left Party
replace party_typeF = 1 if countryelection_FE == 154 //* Centre Party (C)
replace party_typeG = . if countryelection_FE == 154 //* Green Party
replace party_typeH = . if countryelection_FE == 154 //* Sweden Democrats
replace party_typeI = . if countryelection_FE == 154 //* Feminist Party

replace vote_partyA = 39.9 if countryelection_FE == 154 
replace vote_partyB = 15.3 if countryelection_FE == 154 
replace vote_partyC = 13.4 if countryelection_FE == 154 
replace vote_partyD =  9.1 if countryelection_FE == 154 
replace vote_partyE =  8.4 if countryelection_FE == 154 
replace vote_partyF =  6.2 if countryelection_FE == 154 
replace vote_partyG =  . if countryelection_FE == 154 
replace vote_partyH =  . if countryelection_FE == 154 
replace vote_partyI =  . if countryelection_FE == 154 

* Sweden 06 
replace party_typeA = 1 if countryelection_FE == 155 //* SPD
replace party_typeB = 1 if countryelection_FE == 155 //* Moderate
replace party_typeC = 1 if countryelection_FE == 155 //* Centre
replace party_typeD = 1 if countryelection_FE == 155 //* Liberal People's
replace party_typeE = 1 if countryelection_FE == 155 //* Christ Dem
replace party_typeF = 3 if countryelection_FE == 155 //* Left Party
replace party_typeG = 3 if countryelection_FE == 155 //* Green Party
replace party_typeH = 4 if countryelection_FE == 155 //* Sweden Democrats
replace party_typeI = 4 if countryelection_FE == 155 //* Feminist Party

replace vote_partyA = 35.0 if countryelection_FE == 155 
replace vote_partyB = 26.2 if countryelection_FE == 155 
replace vote_partyC =  7.9 if countryelection_FE == 155 
replace vote_partyD =  7.5 if countryelection_FE == 155 
replace vote_partyE =  6.6 if countryelection_FE == 155 
replace vote_partyF =  5.8 if countryelection_FE == 155 
replace vote_partyG =  5.2 if countryelection_FE == 155 
replace vote_partyH =  2.9 if countryelection_FE == 155 
replace vote_partyI =  0.7 if countryelection_FE == 155 

* Sweden 14
replace party_typeA = 1 if countryelection_FE == 156 //* SPD
replace party_typeB = 1 if countryelection_FE == 156 //* Moderate
replace party_typeC = 4 if countryelection_FE == 156 //* Sweden Dem
replace party_typeD = 1 if countryelection_FE == 156 //* Greens
replace party_typeE = 1 if countryelection_FE == 156 //* Centre Party
replace party_typeF = 3 if countryelection_FE == 156 //* Left Party
replace party_typeG = 1 if countryelection_FE == 156 //* Liberal People's
replace party_typeH = 1 if countryelection_FE == 156 //* Christ Dem
replace party_typeI = 4 if countryelection_FE == 156 //* Feminist Party

replace vote_partyA = 31.0  if countryelection_FE == 156 
replace vote_partyB = 23.3  if countryelection_FE == 156 
replace vote_partyC = 12.9  if countryelection_FE == 156 
replace vote_partyD =  6.9  if countryelection_FE == 156 
replace vote_partyE =  6.1  if countryelection_FE == 156 
replace vote_partyF =  5.7  if countryelection_FE == 156 
replace vote_partyG =  5.4  if countryelection_FE == 156 
replace vote_partyH =  4.6  if countryelection_FE == 156 
replace vote_partyI =  3.1  if countryelection_FE == 156 

******* PERCEPTIONS OF POLARISATION (cf. Dalton) *********

****** Party Vote Shares / Weights *******

gen votesA =  vote_partyA
gen votesB =  vote_partyB
gen votesC =  vote_partyC
gen votesD =  vote_partyD
gen votesE =  vote_partyE
gen votesF =  vote_partyF
gen votesG =  vote_partyG
gen votesH =  vote_partyH
gen votesI =  vote_partyI

replace votesA = . if party_typeA != 1
replace votesB = . if party_typeB != 1
replace votesC = . if party_typeC != 1
replace votesD = . if party_typeD != 1
replace votesE = . if party_typeE != 1
replace votesF = . if party_typeF != 1
replace votesG = . if party_typeG != 1
replace votesH = . if party_typeH != 1
replace votesI = . if party_typeI != 1

egen vot_tot = rowtotal(votesA - votesI) 

gen LR_a = LReval_PartyA if party_typeA == 1
gen LR_b = LReval_PartyB if party_typeB == 1
gen LR_c = LReval_PartyC if party_typeC == 1
gen LR_d = LReval_PartyD if party_typeD == 1
gen LR_e = LReval_PartyE if party_typeE == 1
gen LR_f = LReval_PartyF if party_typeF == 1
gen LR_g = LReval_PartyG if party_typeG == 1
gen LR_h = LReval_PartyH if party_typeH == 1
gen LR_i = LReval_PartyI if party_typeI == 1

gen pos_vote_a = LR_a * votesA
gen pos_vote_b = LR_b * votesB
gen pos_vote_c = LR_c * votesC
gen pos_vote_d = LR_d * votesD
gen pos_vote_e = LR_e * votesE
gen pos_vote_f = LR_f * votesF
gen pos_vote_g = LR_g * votesG 
gen pos_vote_h = LR_h * votesH 
gen pos_vote_i = LR_i * votesI

gen posvotA_div_votot = pos_vote_a / vot_tot
gen posvotB_div_votot = pos_vote_b / vot_tot
gen posvotC_div_votot = pos_vote_c / vot_tot
gen posvotD_div_votot = pos_vote_d / vot_tot
gen posvotE_div_votot = pos_vote_e / vot_tot
gen posvotF_div_votot = pos_vote_f / vot_tot
gen posvotG_div_votot = pos_vote_g / vot_tot
gen posvotH_div_votot = pos_vote_h / vot_tot
gen posvotI_div_votot = pos_vote_i / vot_tot

egen pos_tot = rowtotal(posvotA_div_votot - posvotI_div_votot) 

gen m_percepA = LR_a - pos_tot
gen m_percepB = LR_b - pos_tot
gen m_percepC = LR_c - pos_tot 
gen m_percepD = LR_d - pos_tot
gen m_percepE = LR_e - pos_tot
gen m_percepF = LR_f - pos_tot
gen m_percepG = LR_g - pos_tot
gen m_percepH = LR_h - pos_tot
gen m_percepI = LR_i - pos_tot

gen Cm_percepA = m_percepA / 5
gen Cm_percepB = m_percepB / 5
gen Cm_percepC = m_percepC / 5
gen Cm_percepD = m_percepD / 5
gen Cm_percepE = m_percepE / 5
gen Cm_percepF = m_percepF / 5
gen Cm_percepG = m_percepG / 5
gen Cm_percepH = m_percepH / 5
gen Cm_percepI = m_percepI / 5

gen SQRCm_percepA = Cm_percepA * Cm_percepA
gen SQRCm_percepB = Cm_percepB * Cm_percepB
gen SQRCm_percepC = Cm_percepC * Cm_percepC
gen SQRCm_percepD = Cm_percepD * Cm_percepD
gen SQRCm_percepE = Cm_percepE * Cm_percepE
gen SQRCm_percepF = Cm_percepF * Cm_percepF
gen SQRCm_percepG = Cm_percepG * Cm_percepG
gen SQRCm_percepH = Cm_percepH * Cm_percepH
gen SQRCm_percepI = Cm_percepI * Cm_percepI

gen vSQRCm_percepA_2 = (SQRCm_percepA * votesA) / vot_tot
gen vSQRCm_percepB_2 = (SQRCm_percepB * votesB) / vot_tot
gen vSQRCm_percepC_2 = (SQRCm_percepC * votesC) / vot_tot
gen vSQRCm_percepD_2 = (SQRCm_percepD * votesD) / vot_tot
gen vSQRCm_percepE_2 = (SQRCm_percepE * votesE) / vot_tot
gen vSQRCm_percepF_2 = (SQRCm_percepF * votesF) / vot_tot
gen vSQRCm_percepG_2 = (SQRCm_percepG * votesG) / vot_tot
gen vSQRCm_percepH_2 = (SQRCm_percepH * votesH) / vot_tot
gen vSQRCm_percepI_2 = (SQRCm_percepI * votesI) / vot_tot

egen raw_percep = rowtotal(vSQRCm_percepA_2 - vSQRCm_percepI_2) 

gen percepolar = sqrt(raw_percep)

gen MS_RANK_A = 1 if LR_a != . & party_typeA == 1
gen MS_RANK_B = 1 if LR_b != . & party_typeB == 1
gen MS_RANK_C = 1 if LR_c != . & party_typeC == 1
gen MS_RANK_D = 1 if LR_d != . & party_typeD == 1
gen MS_RANK_E = 1 if LR_e != . & party_typeE == 1
gen MS_RANK_F = 1 if LR_f != . & party_typeF == 1
gen MS_RANK_G = 1 if LR_g != . & party_typeG == 1
gen MS_RANK_H = 1 if LR_h != . & party_typeH == 1
gen MS_RANK_I = 1 if LR_i != . & party_typeI == 1

egen MSRANKER = rowtotal(MS_RANK_A - MS_RANK_I)

label variable percepolar "Respondent Weighted Perception of Mainstream Party Polarisation"
replace percepolar =. if MSRANKER < 2
replace percepolar = percepolar * 10
rename percepolar percepolar_MS

***************************** Range *******************************

gen twolargeparty_range = . //* Largest Two Mainstream Parties Compared (Vote Totals)
gen widestms_range = .      //* Furthest Left and Right Parties Compared (Av. Percep). 

replace twolargeparty_range = sqrt((LReval_PartyA - LReval_PartyB)^2) if countryelection == 3 //* Australia (1996)
replace widestms_range = sqrt((LReval_PartyA - LReval_PartyC)^2) if countryelection == 3      //* Australia (1996)

replace twolargeparty_range = sqrt((LReval_PartyA - LReval_PartyB)^2) if countryelection == 4 //* Australia (2004)
replace widestms_range = sqrt((LReval_PartyA - LReval_PartyB)^2) if countryelection == 4      //* Australia (2004)

replace twolargeparty_range = sqrt((LReval_PartyA - LReval_PartyB)^2) if countryelection == 5 //* Australia (2007)
replace widestms_range = sqrt((LReval_PartyA - LReval_PartyB)^2) if countryelection == 5      //* Australia (2007)

replace twolargeparty_range = sqrt((LReval_PartyA - LReval_PartyB)^2) if countryelection == 6 //* Australia (2013)
replace widestms_range = sqrt((LReval_PartyA - LReval_PartyC)^2) if countryelection == 6      //* Australia (2013)

replace twolargeparty_range = sqrt((LReval_PartyA - LReval_PartyB)^2) if countryelection == 7 //* Austria (2008)
replace widestms_range = sqrt((LReval_PartyA - LReval_PartyB)^2) if countryelection == 7      //* Austria (2008)

replace twolargeparty_range = sqrt((LReval_PartyA - LReval_PartyB)^2) if countryelection == 8 //* Austria (2013)
replace widestms_range = sqrt((LReval_PartyA - LReval_PartyB)^2) if countryelection == 8      //* Austria (2013)

replace twolargeparty_range = sqrt((LReval_PartyA - LReval_PartyB)^2) if countryelection == 9 //* Flanders (1999)
replace widestms_range = sqrt((LReval_PartyB - LReval_PartyC)^2) if countryelection == 9      //* Flanders (1999)

replace twolargeparty_range = sqrt((LReval_PartyA - LReval_PartyB)^2) if countryelection == 10 //* Wallonia (1999)
replace widestms_range = sqrt((LReval_PartyB - LReval_PartyD)^2) if countryelection == 10      //* Wallonia (1999)

replace twolargeparty_range = sqrt((LReval_PartyA - LReval_PartyC)^2) if countryelection == 20 //* Canada (1997)
replace widestms_range = sqrt((LReval_PartyC - LReval_PartyD)^2) if countryelection == 20      //* Canada (1997)

replace twolargeparty_range = sqrt((LReval_PartyA - LReval_PartyB)^2) if countryelection == 21 //* Canada (2004)
replace widestms_range = sqrt((LReval_PartyB - LReval_PartyC)^2) if countryelection == 21      //* Canada (2004)

replace twolargeparty_range = sqrt((LReval_PartyA - LReval_PartyB)^2) if countryelection == 22 //* Canada (2008)
replace widestms_range = sqrt((LReval_PartyB - LReval_PartyD)^2) if countryelection == 22      //* Canada (2008)

replace twolargeparty_range = sqrt((LReval_PartyA - LReval_PartyB)^2) if countryelection == 23 //* Canada (2011)
replace widestms_range = sqrt((LReval_PartyA - LReval_PartyB)^2) if countryelection == 23      //* Canada (2011)

replace twolargeparty_range = sqrt((LReval_PartyA - LReval_PartyB)^2) if countryelection == 24 //* Canada (2015)
replace widestms_range = sqrt((LReval_PartyB - LReval_PartyC)^2) if countryelection == 24      //* Canada (2015)

replace twolargeparty_range = sqrt((LReval_PartyB - LReval_PartyC)^2) if countryelection == 25 //* Switz. (1999)
replace widestms_range = sqrt((LReval_PartyB - LReval_PartyC)^2) if countryelection == 25      //* Switz. (1999)

replace twolargeparty_range = sqrt((LReval_PartyB - LReval_PartyC)^2) if countryelection == 26 //* Switz. (2003)
replace widestms_range = sqrt((LReval_PartyB - LReval_PartyC)^2) if countryelection == 26      //* Switz. (2003)

replace twolargeparty_range = sqrt((LReval_PartyB - LReval_PartyC)^2) if countryelection == 27 //* Switz. (2007)
replace widestms_range = sqrt((LReval_PartyB - LReval_PartyG)^2) if countryelection == 27      //* Switz. (2007)

replace twolargeparty_range = sqrt((LReval_PartyB - LReval_PartyC)^2) if countryelection == 28 //* Switz. (2011)
replace widestms_range = sqrt((LReval_PartyB - LReval_PartyC)^2) if countryelection == 28      //* Switz. (2011)

replace twolargeparty_range = sqrt((LReval_PartyA - LReval_PartyB)^2) if countryelection == 37 //* Germany (2002a)
replace widestms_range = sqrt((LReval_PartyD - LReval_PartyC)^2) if countryelection == 37      //* Germany (2002a)

replace twolargeparty_range = sqrt((LReval_PartyA - LReval_PartyB)^2) if countryelection == 38 //* Germany (2002b)
replace widestms_range = sqrt((LReval_PartyC - LReval_PartyD)^2) if countryelection == 38      //* Germany (2002b)

replace twolargeparty_range = sqrt((LReval_PartyA - LReval_PartyB)^2) if countryelection == 39 //* Germany (1998)
replace widestms_range = sqrt((LReval_PartyA - LReval_PartyC)^2) if countryelection == 39      //* Germany (1998)

replace twolargeparty_range = sqrt((LReval_PartyA - LReval_PartyB)^2) if countryelection == 40 //* Germany (2005)
replace widestms_range = sqrt((LReval_PartyE - LReval_PartyF)^2) if countryelection == 40      //* Germany (2005)

replace twolargeparty_range = sqrt((LReval_PartyA - LReval_PartyB)^2) if countryelection == 41 //* Germany (2009)
replace widestms_range = sqrt((LReval_PartyB - LReval_PartyF)^2) if countryelection == 41      //* Germany (2009)

replace twolargeparty_range = sqrt((LReval_PartyA - LReval_PartyB)^2) if countryelection == 42 //* Germany (2013)
replace widestms_range = sqrt((LReval_PartyD - LReval_PartyE)^2) if countryelection == 42      //* Germany (2013)

replace twolargeparty_range = sqrt((LReval_PartyA - LReval_PartyB)^2) if countryelection == 43 //* Denmark (1998)
replace widestms_range = sqrt((LReval_PartyA - LReval_PartyB)^2) if countryelection == 43      //* Denmark (1998)

replace twolargeparty_range = sqrt((LReval_PartyA - LReval_PartyB)^2) if countryelection == 44 //* Denmark (2001)
replace widestms_range = sqrt((LReval_PartyA - LReval_PartyB)^2) if countryelection == 44      //* Denmark (2001)

replace twolargeparty_range = sqrt((LReval_PartyA - LReval_PartyB)^2) if countryelection == 45 //* Denmark (2007)
replace widestms_range = sqrt((LReval_PartyA - LReval_PartyB)^2) if countryelection == 45      //* Denmark (2007)

replace twolargeparty_range = sqrt((LReval_PartyA - LReval_PartyB)^2) if countryelection == 46 //* Spain (1996)
replace widestms_range = sqrt((LReval_PartyA - LReval_PartyB)^2) if countryelection == 46      //* Spain (1996)

replace twolargeparty_range = sqrt((LReval_PartyA - LReval_PartyB)^2) if countryelection == 47 //* Spain (2000)
replace widestms_range = sqrt((LReval_PartyA - LReval_PartyB)^2) if countryelection == 47      //* Spain (2000)

replace twolargeparty_range = sqrt((LReval_PartyA - LReval_PartyB)^2) if countryelection == 48 //* Spain (2004)
replace widestms_range = sqrt((LReval_PartyA - LReval_PartyB)^2) if countryelection == 48      //* Spain (2004)

replace twolargeparty_range = sqrt((LReval_PartyA - LReval_PartyB)^2) if countryelection == 49 //* Spain (2008)
replace widestms_range = sqrt((LReval_PartyE - LReval_PartyB)^2) if countryelection == 49      //* Spain (2008)

replace twolargeparty_range = sqrt((LReval_PartyA - LReval_PartyB)^2) if countryelection == 51 //* Finland (2003)
replace widestms_range = sqrt((LReval_PartyB - LReval_PartyC)^2) if countryelection == 51      //* Finland (2003)

replace twolargeparty_range = sqrt((LReval_PartyA - LReval_PartyB)^2) if countryelection == 52 //* Finland (2007)
replace widestms_range = sqrt((LReval_PartyC - LReval_PartyB)^2) if countryelection == 52      //* Finland (2007)

replace twolargeparty_range = sqrt((LReval_PartyA - LReval_PartyB)^2) if countryelection == 53 //* Finland (2011)
replace widestms_range = sqrt((LReval_PartyA - LReval_PartyB)^2) if countryelection == 53      //* Finland (2011)

replace twolargeparty_range = sqrt((LReval_PartyA - LReval_PartyB)^2) if countryelection == 54 //* Finland (2015)
replace widestms_range = sqrt((LReval_PartyB - LReval_PartyD)^2) if countryelection == 54      //* Finland (2015)

replace twolargeparty_range = sqrt((LReval_PartyA - LReval_PartyB)^2) if countryelection == 56 //* France (2007)
replace widestms_range = sqrt((LReval_PartyA - LReval_PartyB)^2) if countryelection == 56      //* France (2007)

replace twolargeparty_range = sqrt((LReval_PartyA - LReval_PartyB)^2) if countryelection == 58 //* Britain (1997)
replace widestms_range = sqrt((LReval_PartyA - LReval_PartyB)^2) if countryelection == 58      //* Britain (1997)

replace twolargeparty_range = sqrt((LReval_PartyA - LReval_PartyB)^2) if countryelection == 59 //* Britain (2005)
replace widestms_range = sqrt((LReval_PartyA - LReval_PartyB)^2) if countryelection == 59      //* Britain (2005)

replace twolargeparty_range = sqrt((LReval_PartyA - LReval_PartyB)^2) if countryelection == 60 //* Britain (2015)
replace widestms_range = sqrt((LReval_PartyA - LReval_PartyB)^2) if countryelection == 60      //* Britain (2015)

replace twolargeparty_range = sqrt((LReval_PartyA - LReval_PartyB)^2) if countryelection == 61 //* Greece (2009)
replace widestms_range = sqrt((LReval_PartyA - LReval_PartyB)^2) if countryelection == 61      //* Greece (2009)

replace twolargeparty_range = sqrt((LReval_PartyA - LReval_PartyC)^2) if countryelection == 62 //* Greece (2012)
replace widestms_range = sqrt((LReval_PartyA - LReval_PartyC)^2) if countryelection == 62      //* Greece (2012)

replace twolargeparty_range = sqrt((LReval_PartyB - LReval_PartyG)^2) if countryelection == 63 //* Greece (2015)
replace widestms_range = sqrt((LReval_PartyB - LReval_PartyG)^2) if countryelection == 63      //* Greece (2015)

replace twolargeparty_range = sqrt((LReval_PartyA - LReval_PartyB)^2) if countryelection == 72 //* Ireland (2002)
replace widestms_range = sqrt((LReval_PartyA - LReval_PartyC)^2) if countryelection == 72      //* Ireland (2002)

replace twolargeparty_range = sqrt((LReval_PartyA - LReval_PartyB)^2) if countryelection == 73 //* Ireland (2007)
replace widestms_range = sqrt((LReval_PartyC - LReval_PartyF)^2) if countryelection == 73      //* Ireland (2007)

replace twolargeparty_range = sqrt((LReval_PartyA - LReval_PartyB)^2) if countryelection == 74 //* Ireland (2011)
replace widestms_range = sqrt((LReval_PartyA - LReval_PartyF)^2) if countryelection == 74      //* Ireland (2011)

replace twolargeparty_range = sqrt((LReval_PartyA - LReval_PartyB)^2) if countryelection == 75 //* Iceland (1999)
replace widestms_range = sqrt((LReval_PartyA - LReval_PartyB)^2) if countryelection == 75      //* Iceland (1999)

replace twolargeparty_range = sqrt((LReval_PartyA - LReval_PartyB)^2) if countryelection == 76 //* Iceland (2003)
replace widestms_range = sqrt((LReval_PartyA - LReval_PartyB)^2) if countryelection == 76      //* Iceland (2003)

replace twolargeparty_range = sqrt((LReval_PartyA - LReval_PartyB)^2) if countryelection == 77 //* Iceland (2007)
replace widestms_range = sqrt((LReval_PartyA - LReval_PartyB)^2) if countryelection == 77      //* Iceland (2007)

replace twolargeparty_range = sqrt((LReval_PartyA - LReval_PartyB)^2) if countryelection == 78 //* Iceland (2009)
replace widestms_range = sqrt((LReval_PartyA - LReval_PartyB)^2) if countryelection == 78      //* Iceland (2009)

replace twolargeparty_range = sqrt((LReval_PartyA - LReval_PartyB)^2) if countryelection == 79 //* Iceland (2013)
replace widestms_range = sqrt((LReval_PartyA - LReval_PartyC)^2) if countryelection == 79      //* Iceland (2013)

replace twolargeparty_range = sqrt((LReval_PartyB - LReval_PartyA)^2) if countryelection == 84 //* Italy (2006)
replace widestms_range = sqrt((LReval_PartyB - LReval_PartyA)^2) if countryelection == 84      //* Italy (2006)

replace twolargeparty_range = sqrt((LReval_PartyA - LReval_PartyC)^2) if countryelection == 107 //* Netherlands (1998)
replace widestms_range = sqrt((LReval_PartyA - LReval_PartyB)^2) if countryelection == 107      //* Netherlands (1998)

replace twolargeparty_range = sqrt((LReval_PartyA - LReval_PartyC)^2) if countryelection == 108 //* Netherlands (2002)
replace widestms_range = sqrt((LReval_PartyC - LReval_PartyG)^2) if countryelection == 108      //* Netherlands (2002)

replace twolargeparty_range = sqrt((LReval_PartyA - LReval_PartyB)^2) if countryelection == 109 //* Netherlands (2006)
replace widestms_range = sqrt((LReval_PartyB - LReval_PartyD)^2) if countryelection == 109      //* Netherlands (2006)

replace twolargeparty_range = sqrt((LReval_PartyA - LReval_PartyB)^2) if countryelection == 110 //* Netherlands (2010)
replace widestms_range = sqrt((LReval_PartyA - LReval_PartyB)^2) if countryelection == 110      //* Netherlands (2010)

replace twolargeparty_range = sqrt((LReval_PartyA - LReval_PartyC)^2) if countryelection == 111 //* Norway (1997)
replace widestms_range = sqrt((LReval_PartyC - LReval_PartyE)^2) if countryelection == 111      //* Norway (1997)

replace twolargeparty_range = sqrt((LReval_PartyA - LReval_PartyB)^2) if countryelection == 112 //* Norway (2001)
replace widestms_range = sqrt((LReval_PartyB - LReval_PartyG)^2) if countryelection == 112      //* Norway (2001)

replace twolargeparty_range = sqrt((LReval_PartyA - LReval_PartyC)^2) if countryelection == 113 //* Norway (2005)
replace widestms_range = sqrt((LReval_PartyA - LReval_PartyC)^2) if countryelection == 113      //* Norway (2005)

replace twolargeparty_range = sqrt((LReval_PartyA - LReval_PartyB)^2) if countryelection == 114 //* Norway (2009)
replace widestms_range = sqrt((LReval_PartyA - LReval_PartyB)^2) if countryelection == 114      //* Norway (2009)

replace twolargeparty_range = sqrt((LReval_PartyA - LReval_PartyB)^2) if countryelection == 115 //* Norway (2013)
replace widestms_range = sqrt((LReval_PartyA - LReval_PartyC)^2) if countryelection == 115      //* Norway (2013)

replace twolargeparty_range = sqrt((LReval_PartyA - LReval_PartyB)^2) if countryelection == 116 //* New Zealand (1996)
replace widestms_range = sqrt((LReval_PartyA - LReval_PartyB)^2) if countryelection == 116      //* New Zealand (1996)

replace twolargeparty_range = sqrt((LReval_PartyA - LReval_PartyB)^2) if countryelection == 117 //* New Zealand (2002)
replace widestms_range = sqrt((LReval_PartyB - LReval_PartyE)^2) if countryelection == 117      //* New Zealand (2002)

replace twolargeparty_range = sqrt((LReval_PartyA - LReval_PartyB)^2) if countryelection == 118 //* New Zealand (2008)
replace widestms_range = sqrt((LReval_PartyE - LReval_PartyC)^2) if countryelection == 118      //* New Zealand (2008)

replace twolargeparty_range = sqrt((LReval_PartyA - LReval_PartyB)^2) if countryelection == 119 //* New Zealand (2011)
replace widestms_range = sqrt((LReval_PartyA - LReval_PartyB)^2) if countryelection == 119      //* New Zealand (2011)

replace twolargeparty_range = sqrt((LReval_PartyA - LReval_PartyB)^2) if countryelection == 120 //* New Zealand (2014)
replace widestms_range = sqrt((LReval_PartyC - LReval_PartyH)^2) if countryelection == 120      //* New Zealand (2014)

replace twolargeparty_range = sqrt((LReval_PartyA - LReval_PartyB)^2) if countryelection == 134 //* Portugal (2002)
replace widestms_range = sqrt((LReval_PartyB - LReval_PartyC)^2) if countryelection == 134      //* Portugal (2002)

replace twolargeparty_range = sqrt((LReval_PartyA - LReval_PartyB)^2) if countryelection == 135 //* Portugal (2005)
replace widestms_range = sqrt((LReval_PartyA - LReval_PartyD)^2) if countryelection == 135      //* Portugal (2005)

replace twolargeparty_range = sqrt((LReval_PartyA - LReval_PartyB)^2) if countryelection == 136 //* Portugal (2009)
replace widestms_range = sqrt((LReval_PartyA - LReval_PartyB)^2) if countryelection == 136      //* Portugal (2009)

replace twolargeparty_range = sqrt((LReval_PartyA - LReval_PartyB)^2) if countryelection == 137 //* Portugal (2015)
replace widestms_range = sqrt((LReval_PartyA - LReval_PartyB)^2) if countryelection == 137      //* Portugal (2015)

replace twolargeparty_range = sqrt((LReval_PartyA - LReval_PartyB)^2) if countryelection == 153 //* Sweden (1998)
replace widestms_range = sqrt((LReval_PartyA - LReval_PartyB)^2) if countryelection == 153      //* Sweden (1998)

replace twolargeparty_range = sqrt((LReval_PartyA - LReval_PartyB)^2) if countryelection == 154 //* Sweden (2002)
replace widestms_range = sqrt((LReval_PartyA - LReval_PartyB)^2) if countryelection == 154      //* Sweden (2002)

replace twolargeparty_range = sqrt((LReval_PartyA - LReval_PartyB)^2) if countryelection == 155 //* Sweden (2006)
replace widestms_range = sqrt((LReval_PartyA - LReval_PartyB)^2) if countryelection == 155      //* Sweden (2006)

replace twolargeparty_range = sqrt((LReval_PartyA - LReval_PartyB)^2) if countryelection == 156 //* Sweden (2014)
replace widestms_range = sqrt((LReval_PartyA - LReval_PartyB)^2) if countryelection == 156      //* Sweden (2014)


label variable twolargeparty_range "Respondent Perception of Two Largest (votes) Mainstream Parties Polarisation"
label variable widestms_range "Respondent Perception of LeftMost and RightMost (av.percep) Mainstream Parties Polarisation"
order percepolar twolargeparty_range widestms_range, after(self_rad2)


***** Partisanship *****

recode IMD3005_1 (1 = 1 "Has a PID") (5=0 "Does not have a PID") (8=0) (else=.), gen (PID_has)
label variable PID_has "Respondent Has a Partisan Identification [PID] (With any Party)"
replace PID_has = 0 if IMD3005_3 == 9999997 | IMD3005_3 == 9999999 //* Name of party missing / DK
drop IMD3005_1

recode IMD3005_2 (1 = 1 "Feels closer to one party") (5 = 0 "Does not feel closer to one party") (8=0) (else=.), gen(close_feels)
label variable close_feels "Respondent Feels Closer to One Particular Oarty"
replace close_feels = 0 if IMD3005_3 == 9999997 | IMD3005_3 == 9999999 //* Name of party missing / DK
drop IMD3005_2

gen PIDclose_has =.
label variable PIDclose_has "Respondent Has a PID or Feels Closer to One Particular Party"
replace PIDclose_has = 1 if PID_has == 1 | close_feels == 1
replace PIDclose_has = 0 if PIDclose != 1
replace PIDclose_has = 0 if IMD3005_3 == 9999997 | IMD3005_3 == 9999999
label define PIDclose_has 1 "R has a PID or feels close to one party" 0 "R has no PID and does not feel close to one party" , replace
label values PIDclose_has PIDclose_has

gen PID_degree =.
label variable PID_degree "Does Respondent Have a PID/Close Party and to What Extent are they Close?"
label define PID_degree 4 "Very close" 3 "Somewhat close" 2 "Not very close" 1 "No PID/closeness",replace
label values PID_degree PID_degree
replace PID_degree = 4 if IMD3005_4 == 1
replace PID_degree = 3 if IMD3005_4 == 2 
replace PID_degree = 2 if IMD3005_4 == 3
replace PID_degree = 1 if PIDclose_has == 0
replace PID_degree = 3 if PID_degree ==. & PIDclose_has == 1
replace PID_degree = 1 if IMD3005_3 == 9999997 | IMD3005_3 == 9999999 //* Name of party missing / DK
replace PID_degree =. if IMD3005_3 == 9999998 //* Get rid of observations that refused to divulge their party ID.

gen PID_dummy =.
label variable PID_dummy "Does Respondent Have a PID/Close Party? (At Least 'Somewhat' Close)"
label define PID_dummy 1 "Respondent has a PID/close party" 0 "Respondent does not have a PID/close party" , replace
label values PID_dummy PID_dummy
replace PID_dummy = 1 if inlist(PID_degree,4,3)
replace PID_dummy = 0 if inlist(PID_degree,2,1)
replace PID_dummy =. if IMD3005_3 == 9999998
drop IMD3005_4

rename IMD3005_3 PID_who
label variable PID_who "Name of Respondents' PID/Close Party (Original CSES Codes)"

order PID_has close_feels PIDclose_has PID_degree PID_dummy PID_who, after(widestms_range)

***** Turnout ****

gen list_dom =. //* Use list system for these countries (Germany)
replace list_dom = 1 if inlist(country_FE,4,6,13,15,17,19,22,25,33,35,39,47,48,49)
replace list_dom = 0 if list_dom !=1
label variable list_dom "List-Dominant Electoral System or District-Dominant?"
label define list_dom 1 "List-Dominant Electoral System" 0 "District-Dominant Electoral System"
label values list_dom list_dom

gen turnout_1 = .
replace turnout_1 = 1 if IMD3001_LH == 1
replace turnout_1 = 0 if IMD3001_LH == 0
replace turnout_1 = 0 if IMD3001_LH == 9999993 //* Not registered 
replace turnout_1 = 0 if IMD3001_LH == 9999998 //* Don't know if voted?
replace turnout_1 = 0 if IMD3002_LH_PL == 9999993 //* Cast a blank ballot
replace turnout_1 = 0 if IMD3002_LH_DC == 9999993 //* Cast a blank ballot
replace turnout_1 = 0 if IMD3002_LH_PL == 9999998 & list_dom == 1 //* Don't Know Vote Choice
replace turnout_1 = 0 if IMD3002_LH_DC == 9999998 & list_dom == 0 //* Don't Know Vote Choice
replace turnout_1 = 0 if IMD3002_LH_PL == 9999999 & list_dom == 1 //* Vote choice missing/abstained
replace turnout_1 = 0 if IMD3002_LH_DC == 9999999 & list_dom == 0 //* Vote choice missing/abstained
label variable turnout_1 "Did Respondent Cast a Vote in Lower House Parl Election"
label define turnout_1 1 "Respondent Cast a Vote in Lower House Parl Election" 0 "Respondent Did Not Cast a Vote in Lower House Parl Election" , replace
label values turnout_1 turnout_1
drop IMD3001_LH

**** Vote Choice ****

label define partynames 1 "SPO" 2 "OVP" 3 "FPO" 4 "BZO" 5 "Austrian Greens" 6 "Communist Party of Austria" 7 "Liberal Forum" 8 "NEOS" 9 "Team Stronach" 10 "Dinkhauser' List" 11 "Citizen's Forum Austria" ///
            12 "NVA" 13 "Walloon Socialists" 14 "Flemish Christ Dems" 15 "Flemish Liberals" 16 "Flemish Socialists" 17 "Walloon Christ Dems" 18 "Flemish Bloc" 19 "Walloon Greens" ///
			20 "People's Union" 21 "Walloon Liberals" 22 "RESIST" 23 "Flemish Greens" 24 "Walloon National Front" 25 "Workers' Party of Belgium" 26 "Walloon Christ Dems 2" ///
			27 "Vivant" 28 "Walloon Libs" 29 "Danish SDP" 30 "Venstre" 31 "Progress Party" 32 "Socialist People's Party" 33 "Red-Green Party" 34 "Danish Social Liberals" ///
			35 "Conservative People's Party" 36 "Christian Democrats" 37 "New Alliance" 38 "Danish People's Party" 39 "Centre Democrats" 40 "Democratic Renewal" 41 "Center Party" ///
			42 "Finland SDP" 43 "KoK" 44 "True Finns" 45 "Green League" 46 "Left Alliance" 47 "Christian Democrats" 48 "Swedish People's Party" 49 "Independence Party" ///
			50 "For Peace and Socialism" 51 "Liberal People's Party" 52 "Change 2011" 53 "Pirate Party" 54 "Finnish Senior Citizens" 55 "Communist Party of Finland" ///
			56 "Finnish Workers' Party" 57 "Finnish Freedom Party" 58 "CDU-CSU" 59 "German SPD" 60 "German Greens" 61 "FDP" 62 "Die Linke" 63 "The Republicans" ///
			64 "NPD" 65 "Alternative for Germany" 66 "Pirate Party" 67 "German People's Union" 68 "South Schleswig Voters'" 69 "The Greys" 70 "Ecological Democratic Party" ///
			71 "Bible Literalists" 72 "Pensioners Party / Greys" 73 "Generation Party" 74 "Schill Party/ Rule of Law" 75 "Free Voters" 76 "Animal Protection Party" ///
			77 "Family Party" 78 "Violet Spiritual Politics" 79 "The Party" 80 "Women's Party" 81 "Alliance Health and Peace" 82 "Civic Movement" 83 "PASOK" ///
			84 "New Democracy" 85 "SYRIZA" 86 "KKE" 87 "Greek Ecologist Greens" 88 "Golden Dawn" 89 "Independent Greeks" 90 "Democratic Left" 91 "The River" 92 "Popular Orthodox Rally" ///
			93 "Independence Party" 94 "SocDem Alliance" 95 "Progressive Party" 96 "Liberal Party" 97 "Left-Green Movement" 98 "Bright Future" 99 "Pirate Party" 100 "Civic Movement" ///
			101 "Right-Green People's Party" 102 "Icelandic Movement" 103 "Dawn" 104 "Icelandic Democratic Party" 105 "Rainbow" 106 "Democratic Movement" 107 "Households Party" ///
			108 "Humanist Party" 109 "Rural Party" 110 "Christian Democrats" 111 "Anarchists" 112 "Forza Italia" 113 "Lega Nord" 114 "Federation of Greens" 115 "Party of Italian Communists" ///
			116 "Christian and Centre Union" 117 "Communist Refoundation Party" 118 "Rose in the Fist" 119 "National Alliance" 120 "Popular-UDEUR" 121 "Christian Democracy" 122 "Social Alternative" ///
			123 "Tricolour Flame" 124 "Socialists" 125 "Terzo Polo" 126 "Solidarieta" 127 "Pensioner's Party" 128 "The Olive" 129 "Christian Democratic Appeal" 130 "Dutch Labor Party" ///
			131 "People's Party for Freedom and Democracy" 132 "Democrats 66" 133 "GreenLeft" 134 "Socialist Party" 135 "Reformed Party" 136 "Christian Union" 137 "Party for Freedom" ///
			138 "Proud of the Netherlands" 139 "One Netherlands" 140 "Party for the Animals" 141 "List Pim Fortuyn" 142 "Local List (Neth.)" 143 "Livable Netherlands" 144 "United Seniors' Party" ///
			145 "Centre Democrats" 146 "Reformed Alliance" 147 "Dutch Greens" 148 "Natural Law Party" 149 "Party for the Future" 150 "Reformed Federation" 151 "Free Indian Party" 152 "Union 55+" ///
			153 "Seniors 2000" 154 "Mobile Netherlands" 155 "Norwegian Labour Party" 156 "Norwegian Conservative Party" 157 "Progress Party" 158 "Socialist Left Party" 159 "Norwegian Green Party" ///
			160 "Center Party" 161 "Christian People's Party" 162 "Liberal Party" 163 "Red Party" 164 "Red Electoral Alliance" 165 "Portuguese SDP" 166 "Portuguese Socialists" 167 "CDS - Popular Party" ///
			168 "PRT Unitarian Democratic Coalition" 169 "Left Bloc" 170 "Portuguese Workers' Communists" 171 "Merit and Society Movement" 172 "Portugal Ahead Coalition" ///
			173 "Earth Party" 174 "Hope for Portugal" 175 "PSOE" 176 "People's Party" 177 "Convergence and Union" 178 "United Left" 179 "Basque Nationalist Party" 180 "Galician Nationalist Bloc" ///
			181 "Republican Left of Catalonia" 182 "Basque Solidarity" 183 "Union, Progress, and Democracy" 184 "Canarian Coalition" 185 "Spanish Ecologists" 186 "Aragonese Party" ///
			187 "Basque Nationalist Coalition" 188 "Herri Batasuna (Popular Unity)" 189 "Valencian Union" 190 "Navarrese People's Union" 191 "Aragonese Council" 192 "Andalusian Party" 193 "Swedish SDP" ///
			194 "Moderate Party" 195 "Liberal People's Party" 196 "Christian Democrats" 197 "Swedish Green Party" 198 "Centre Party" 199 "Left Party" 200 "Sweden Democrats" ///
			201 "Feminist Party" 202 "Swiss People's Party" 203 "Swiss SDP" 204 "Christian Democratic People's Party" 205 "FDP: Liberals" 206 "Green Party of Switzerland" ///
			207 "Evangelical People's Party" 208 "Swiss Party of Labour" 209 "Ticino League" 210 "Federal Democratic Union" 211 "Swiss Democrats" 212 "Solidarity" ///
			213 "Swiss Freedom Party" 214 "Liberal Party" 215 "Feminist and Greens" 216 "Center Parties Switz" 217 "Independent Alliance" 218 "Geneva Citizen's Movement" ///
			219 "Radical Democratic Party (FDP: Liberals)" 220 "Conservative Democratic Party" 221 "Christian Social Party" 222 "Liberal Party of Australia" ///
			223 "National Party of Australia" 224 "Labor Party of Australia" 225 "Australian Democrats" 226 "Australian Greens" 227 "One Nation Party" 228 "Christian Democratic Party" ///
			229 "Australian Sex Party" 230 "Family First Party" 231 "Katter's Australian Party" 232 "Palmer UTD Party" 233 "Citizen's Electoral Council" 234 "Motoring Enthusiasts Party" ///
			235 "Fishing Party" 236 "Wikileaks Party" 237 "Australian Christians" 238 "Canadian Liberal Party" 239 "Canadian Conservative Party" 240 "New Democratic Party" ///
			241 "Bloc Qubecois" 242 "Canadian Green Party" 243 "Progressive Conservative Party" 244 "Reform Party" 245 "Marijuana Party" 246 "UMP" 247 "Socialist Party" ///
			248 "Democratic Movement" 249 "French Communist Party" 250 "Europe Ecology - Greens" 251 "National Front" 252 "Movement for France" 253 "Hunting, Fishing, Nature" ///
			254 "Radical Party of the Left" 255 "French Miscellaneous Left" 256 "New Centre" 257 "French Miscellaneous Right" 258 "Regionalists" 259 "Fianna Fail" ///
			260 "Fine Gael" 261 "Labour Party of Ireland" 262 "Sinn Fein" 263 "Irish Greens" 264 "Progressive Democrats" 265 "Socialist Party" 266 "Workers' Party" ///
			267 "People before Profit" 268 "Fathers' Rights" 269 "NZ National Party" 270 "NZ Labour Party" 271 "New Zealand First" 272 "ACT New Zealand" 273 "NZ Green Party" ///
			274 "United Future NZ" 275 "Conservative Party" 276 "Maori Party" 277 "Alliance Party" 278 "Internet MANA Party" 279 "MANA Movement" 280 "Anderton Progressive Party" ///
			281 "Christian Heritage Party" 282 "United NZ" 283 "NZ Conservative" 284 "NZ Pacific Party" 285 "NZ Libertarian" 286 "Progressive Greens" 287 "Workers' Party NZ" ///
			288 "Mana Maori" 289 "NZ Libertarian" 290 "Kiwi Party" 291 "Family Party" 292 "Residents' Action Movement" 293 "Republic of NZ Party" 294 "McGillicuddy Serious" ///
			295 "Democrats for Social Credit" 296 "Outdoor Recreation NZ" 297 "Christian Coalition" 298 "Leagalise Cannabis" 299 "Conservatives" 300 "Labour Party" 301 "Liberal Democrats" ///
			302 "Scottish National Party" 303 "Green Party" 304 "Plaid Cymru" 305 "Recreate Greece" 306 "Anticapitalist Left" 307 "Action Greece" 308 "Union of Centrists (Greece)" ///
			309 "Movement of Democrats" 310 "Icelandic SDP" 311 "People's Alliance Iceland" 312 "Liberal Democratic Australia" 313 "Australian Shooters' Party" 314 "Pirate Party of Austria" ///
			315 "Canadian Heritage Party" 316 "For the Poor" 317 "Workers' Struggle" 318 "Revolutionary Communists" 319 "Bavarian Party" 320 "Pirate Party" 321 "People's Movement" ///
			321 "New Movement Iceland" 322 "Italy of Values" 323 "The Daisy" 324 "The Union" 325 "House of Freedoms" 326 "Dutch Communist Party" 327 "Pacifist Socialist Party" ///
			328 "Future NZ" 329 "NZ Democrats" 330 "Bill and Ben Party" 331 "Portuguese Greens" 332 "Revolutionary Communists (Port.)" 333 "Popular Democratic Union (Port.)" 334 "Portuguese Humanists" ///
			335 "Mallorcan Socialists" 336 "Swiss Progressives" 337 "Autonomous Socialists (Switz.)" 338 "Christian People's Party (Switz)" 339 "Independent Candidates" 340 "Other Left-Wing Parties" ///
			341 "Other Right-Wing Parties" 342 "Other Parties" 343 "Green Liberals (Switz)" 344 "Canarian Independents" 345 "Nafarroa Bai (Navarre Yes)" 346 "UKIP" 347 "Democratic Revival" ///
			348 "Citizen’s Party" 349 "Women’s Alliance" 350 "Monarchists" 351 "Humanists", replace
			
label define partytypes_long 1 "Mainstream Party" 2 "Comp Left" 3 "Comp Right" 4 "Halfway Left" 5 "Halfway Right" 6 "Antisystem Left" 7 "Antisystem Right"
label define partytypes_short 1 "Mainstream Party" 2 "Complementary Party" 3 "Halfway-House Party" 4 "Anti-System Party" 
label define incumbentvoting_long 1 "Incumbent Mainstream Party" 2 "Opposition Mainstream Party" 3 "Comp Left" 4 "Comp Right" 5 "Halfway Left" 6 "Halfway Right" 7 "Antisystem Left" 8 "Antisystem Right" 
label define incumbentvoting_short 1 "Incumbent Mainstream Party" 2 "Opposition Mainstream Party" 3 "Complementary Party" 4 "Halfway-House Party" 5 "Anti-System Party" 

gen incumbent_PID =.
gen incumbent_voted =.
gen party_voted =.
gen type_voted =.
gen party_PID =.
gen type_PID =.

label variable party_voted "Which Party did the Respondent Vote for?"
label variable party_PID "Which Party does the Respondent have a PID to?"
label variable incumbent_voted "Did the Respondent Vote for the Previous Incumbent?"
label variable incumbent_PID "Is Respondent's PID the Previous Incumbent?"
label variable type_voted "What Type of Party Did the Respondent Vote for?"
label variable type_PID "What Type of Party Does the Respondent have a PID with?"

label values party_voted party_PID partynames
label values type_voted type_PID partytypes_long

gen type_votedSHORT =.
label variable type_votedSHORT "What Type of Party did the Respondent Vote for? (Short)"
label values type_votedSHORT partytypes_short
replace type_votedSHORT = 1 if type_voted == 1
replace type_votedSHORT = 2 if type_voted == 2 | type_voted == 3
replace type_votedSHORT = 3 if type_voted == 4 | type_voted == 5
replace type_votedSHORT = 4 if type_voted == 6

gen type_votedLONG =.
label variable type_votedLONG "What Type of Party did the Respondent Vote for? (Long)"
label values type_votedLONG partytypes_long
replace type_votedLONG = type_voted

replace party_voted = 339 if IMD3002_LH_DC == 9999989 | IMD3002_LH_PL == 9999989 //* Independent
replace party_PID = 339 if PID_who == 9999989
replace type_voted = 2 if IMD3002_LH_DC == 9999989 | IMD3002_LH_PL == 9999989
replace type_PID = 2 if PID_who == 9999989

replace party_voted = 342 if IMD3002_LH_PL == 9999992 | IMD3002_LH_DC == 9999992 //* Other
replace party_PID = 342 if PID_who == 9999992
replace type_voted = 2 if IMD3002_LH_PL == 9999992 | IMD3002_LH_DC == 9999992
replace type_PID = 2 if PID_who == 9999992

replace party_voted = 340 if IMD3002_LH_PL == 9999990 | IMD3002_LH_DC == 9999990 | IMD3002_LH_DC == 2500019  //* Other Left
replace party_PID = 340 if PID_who == 9999990 | PID_who == 2500019
replace type_voted = 2 if IMD3002_LH_PL == 9999990 | IMD3002_LH_DC == 9999990 | IMD3002_LH_DC == 2500019
replace type_PID = 2 if PID_who == 9999990 | PID_who == 2500019

replace party_voted = 341 if IMD3002_LH_PL == 9999991 | IMD3002_LH_DC == 9999990 | IMD3002_LH_DC == 2500021  //* Other Right
replace party_PID = 341 if PID_who == 9999991 | PID_who == 2500021
replace type_voted = 3 if IMD3002_LH_PL == 9999991 | IMD3002_LH_DC == 9999990 | IMD3002_LH_DC == 2500021
replace type_PID = 3 if PID_who == 9999991 | PID_who == 2500021

//* Australia 1996 

replace incumbent_voted = 1 if countryelection_FE == 3 & IMD3002_LH_DC == 360003 //* Labour
replace incumbent_PID = 1 if countryelection_FE == 3 & PID_who == 360003 //* Labour

replace party_voted = 222 if countryelection_FE == 3 & IMD3002_LH_DC == 360001 //* Liberal
replace party_PID = 222 if countryelection_FE == 3 & PID_who == 360001
replace type_voted = 1 if countryelection_FE == 3 & IMD3002_LH_DC == 360001
replace type_PID = 1 if countryelection_FE == 3 & PID_who == 360001

replace party_voted = 223 if countryelection_FE == 3 & IMD3002_LH_DC == 360002 //* National
replace party_PID = 223 if countryelection_FE == 3 & PID_who == 360002
replace type_voted = 1 if countryelection_FE == 3 & IMD3002_LH_DC == 360002
replace type_PID = 1 if countryelection_FE == 3 & PID_who == 360002

replace party_voted = 224 if countryelection_FE == 3 & IMD3002_LH_DC == 360003 //* Labour
replace party_PID = 224 if countryelection_FE == 3 & PID_who == 360003
replace type_voted = 1 if countryelection_FE == 3 & IMD3002_LH_DC == 360003
replace type_PID = 1 if countryelection_FE == 3 & PID_who == 360003

replace party_voted = 225 if countryelection_FE == 3 & IMD3002_LH_DC == 360004 //* Aus Democrats
replace party_PID = 225 if countryelection_FE == 3 & PID_who == 360004
replace type_voted = 2 if countryelection_FE == 3 & IMD3002_LH_DC == 360004
replace type_PID = 2 if countryelection_FE == 3 & PID_who == 360004

replace party_voted = 226 if countryelection_FE == 3 & IMD3002_LH_DC == 360005 //* Aus Greens
replace party_PID = 226 if countryelection_FE == 3 & PID_who == 360005
replace type_voted = 2 if countryelection_FE == 3 & IMD3002_LH_DC == 360005
replace type_PID = 2 if countryelection_FE == 3 & PID_who == 360005

replace party_voted = 312 if countryelection_FE == 3 & IMD3002_LH_DC == 360007 //* LibDem Australia
replace party_PID = 312 if countryelection_FE == 3 & PID_who == 360007
replace type_voted = 3 if countryelection_FE == 3 & IMD3002_LH_DC == 360007
replace type_PID = 3 if countryelection_FE == 3 & PID_who == 360007

replace party_voted = 313 if countryelection_FE == 3 & IMD3002_LH_DC == 360015 //* Shooters
replace party_PID = 313 if countryelection_FE == 3 & PID_who == 360015
replace type_voted = 3 if countryelection_FE == 3 & IMD3002_LH_DC == 360015
replace type_PID = 3 if countryelection_FE == 3 & PID_who == 360015


//* Australia 2004

replace incumbent_voted = 1 if countryelection_FE == 4 & IMD3002_LH_DC == 360001  | IMD3002_LH_DC == 360002 //* Lib-Nat
replace incumbent_PID = 1 if countryelection_FE == 4 & PID_who == 360001  |  PID_who == 360002 //* Lib-Nat

replace party_voted = 222 if countryelection_FE == 4 & IMD3002_LH_DC == 360001 //* Liberal
replace party_PID = 222 if countryelection_FE == 4 & PID_who == 360001
replace type_voted = 1 if countryelection_FE == 4 & IMD3002_LH_DC == 360001
replace type_PID = 1 if countryelection_FE == 4 & PID_who == 360001

replace party_voted = 223 if countryelection_FE == 4 & IMD3002_LH_DC == 360002 //* National
replace party_PID = 223 if countryelection_FE == 4 & PID_who == 360002
replace type_voted = 1 if countryelection_FE == 4 & IMD3002_LH_DC == 360002
replace type_PID = 1 if countryelection_FE == 4 & PID_who == 360002

replace party_voted = 224 if countryelection_FE == 4 & IMD3002_LH_DC == 360003 //* Labour
replace party_PID = 224 if countryelection_FE == 4 & PID_who == 360003
replace type_voted = 1 if countryelection_FE == 4 & IMD3002_LH_DC == 360003
replace type_PID = 1 if countryelection_FE == 4 & PID_who == 360003

replace party_voted = 225 if countryelection_FE == 4 & IMD3002_LH_DC == 360004 //* Aus Democrats
replace party_PID = 225 if countryelection_FE == 4 & PID_who == 360004
replace type_voted = 2 if countryelection_FE == 4 & IMD3002_LH_DC == 360004
replace type_PID = 2 if countryelection_FE == 4 & PID_who == 360004

replace party_voted = 226 if countryelection_FE == 4 & IMD3002_LH_DC == 360005 //* Aus Greens
replace party_PID = 226 if countryelection_FE == 4 & PID_who == 360005
replace type_voted = 2 if countryelection_FE == 4 & IMD3002_LH_DC == 360005
replace type_PID = 2 if countryelection_FE == 4 & PID_who == 360005

replace party_voted = 227 if countryelection_FE == 4 & IMD3002_LH_DC == 360008 //* One Nation Party
replace party_PID = 227 if countryelection_FE == 4 & PID_who == 360008
replace type_voted = 7 if countryelection_FE == 4 & IMD3002_LH_DC == 360008
replace type_PID = 7 if countryelection_FE == 4 & PID_who == 360008

replace party_voted = 228 if countryelection_FE == 4 & IMD3002_LH_DC == 360009 //* Christian Democratic Party
replace party_PID = 228 if countryelection_FE == 4 & PID_who == 360009
replace type_voted = 3 if countryelection_FE == 4 & IMD3002_LH_DC == 360009
replace type_PID = 3 if countryelection_FE == 4 & PID_who == 360009

replace party_voted = 230 if countryelection_FE == 4 & IMD3002_LH_DC == 360011 //* Family First
replace party_PID = 230 if countryelection_FE == 4 & PID_who == 360011
replace type_voted = 3 if countryelection_FE == 4 & IMD3002_LH_DC == 360011
replace type_PID = 3 if countryelection_FE == 4 & PID_who == 360011

replace party_voted = 312 if countryelection_FE == 4 & IMD3002_LH_DC == 360007 //* LibDem Australia
replace party_PID = 312 if countryelection_FE == 4 & PID_who == 360007
replace type_voted = 3 if countryelection_FE == 4 & IMD3002_LH_DC == 360007
replace type_PID = 3 if countryelection_FE == 4 & PID_who == 360007

replace party_voted = 313 if countryelection_FE == 4 & IMD3002_LH_DC == 360015 //* Shooters
replace party_PID = 313 if countryelection_FE == 4 & PID_who == 360015
replace type_voted = 3 if countryelection_FE == 4 & IMD3002_LH_DC == 360015
replace type_PID = 3 if countryelection_FE == 4 & PID_who == 360015

//* Australia 2007

replace incumbent_voted = 1 if countryelection_FE == 5 & IMD3002_LH_DC == 360001  | IMD3002_LH_DC == 360002 //* Lib-Nat
replace incumbent_PID = 1 if countryelection_FE == 5 & PID_who == 360001  |  PID_who == 360002 //* Lib-Nat

replace party_voted = 222 if countryelection_FE == 5 & IMD3002_LH_DC == 360001 //* Liberal
replace party_PID = 222 if countryelection_FE == 5 & PID_who == 360001
replace type_voted = 1 if countryelection_FE == 5 & IMD3002_LH_DC == 360001
replace type_PID = 1 if countryelection_FE == 5 & PID_who == 360001

replace party_voted = 223 if countryelection_FE == 5 & IMD3002_LH_DC == 360002 //* National
replace party_PID = 223 if countryelection_FE == 5 & PID_who == 360002
replace type_voted = 1 if countryelection_FE == 5 & IMD3002_LH_DC == 360002
replace type_PID = 1 if countryelection_FE == 5 & PID_who == 360002

replace party_voted = 224 if countryelection_FE == 5 & IMD3002_LH_DC == 360003 //* Labour
replace party_PID = 224 if countryelection_FE == 5 & PID_who == 360003
replace type_voted = 1 if countryelection_FE == 5 & IMD3002_LH_DC == 360003
replace type_PID = 1 if countryelection_FE == 5 & PID_who == 360003

replace party_voted = 225 if countryelection_FE == 5 & IMD3002_LH_DC == 360004 //* Aus Democrats
replace party_PID = 225 if countryelection_FE == 5 & PID_who == 360004
replace type_voted = 2 if countryelection_FE == 5 & IMD3002_LH_DC == 360004
replace type_PID = 2 if countryelection_FE == 5 & PID_who == 360004

replace party_voted = 226 if countryelection_FE == 5 & IMD3002_LH_DC == 360005 //* Aus Greens
replace party_PID = 226 if countryelection_FE == 5 & PID_who == 360005
replace type_voted = 2 if countryelection_FE == 5 & IMD3002_LH_DC == 360005
replace type_PID = 2 if countryelection_FE == 5 & PID_who == 360005

replace party_voted = 227 if countryelection_FE == 5 & IMD3002_LH_DC == 360008 //* One Nation Party
replace party_PID = 227 if countryelection_FE == 5 & PID_who == 360008
replace type_voted = 7 if countryelection_FE == 5 & IMD3002_LH_DC == 360008
replace type_PID = 7 if countryelection_FE == 5 & PID_who == 360008

replace party_voted = 228 if countryelection_FE == 5 & IMD3002_LH_DC == 360009 //* Christian Democratic Party
replace party_PID = 228 if countryelection_FE == 5 & PID_who == 360009
replace type_voted = 3 if countryelection_FE == 5 & IMD3002_LH_DC == 360009
replace type_PID = 3 if countryelection_FE == 5 & PID_who == 360009

replace party_voted = 230 if countryelection_FE == 5 & IMD3002_LH_DC == 360011 //* Family First
replace party_PID = 230 if countryelection_FE == 5 & PID_who == 360011
replace type_voted = 3 if countryelection_FE == 5 & IMD3002_LH_DC == 360011
replace type_PID = 3 if countryelection_FE == 5 & PID_who == 360011

replace party_voted = 312 if countryelection_FE == 5 & IMD3002_LH_DC == 360007 //* LibDem Australia
replace party_PID = 312 if countryelection_FE == 5 & PID_who == 360007
replace type_voted = 3 if countryelection_FE == 5 & IMD3002_LH_DC == 360007
replace type_PID = 3 if countryelection_FE == 5 & PID_who == 360007

replace party_voted = 313 if countryelection_FE == 5 & IMD3002_LH_DC == 360015 //* Shooters
replace party_PID = 313 if countryelection_FE == 5 & PID_who == 360015
replace type_voted = 3 if countryelection_FE == 5 & IMD3002_LH_DC == 360015
replace type_PID = 3 if countryelection_FE == 5 & PID_who == 360015

//* Australia 2013

replace incumbent_voted = 1 if countryelection_FE == 6 & IMD3002_LH_DC == 360003  //* Labour
replace incumbent_PID = 1 if countryelection_FE == 6 & PID_who == 360003 //* Labour

replace party_voted = 222 if countryelection_FE == 6 & IMD3002_LH_DC == 360001 //* Liberal
replace party_PID = 222 if countryelection_FE == 6 & PID_who == 360001
replace type_voted = 1 if countryelection_FE == 6 & IMD3002_LH_DC == 360001
replace type_PID = 1 if countryelection_FE == 6 & PID_who == 360001

replace party_voted = 223 if countryelection_FE == 6 & IMD3002_LH_DC == 360002 //* National
replace party_PID = 223 if countryelection_FE == 6 & PID_who == 360002
replace type_voted = 1 if countryelection_FE == 6 & IMD3002_LH_DC == 360002
replace type_PID = 1 if countryelection_FE == 6 & PID_who == 360002

replace party_voted = 224 if countryelection_FE == 6 & IMD3002_LH_DC == 360003 //* Labour
replace party_PID = 224 if countryelection_FE == 6 & PID_who == 360003
replace type_voted = 1 if countryelection_FE == 6 & IMD3002_LH_DC == 360003
replace type_PID = 1 if countryelection_FE == 6 & PID_who == 360003

replace party_voted = 225 if countryelection_FE == 6 & IMD3002_LH_DC == 360004 //* Aus Democrats
replace party_PID = 225 if countryelection_FE == 6 & PID_who == 360004
replace type_voted = 2 if countryelection_FE == 6 & IMD3002_LH_DC == 360004
replace type_PID = 2 if countryelection_FE == 6 & PID_who == 360004

replace party_voted = 226 if countryelection_FE == 6 & IMD3002_LH_DC == 360005 //* Aus Greens
replace party_PID = 226 if countryelection_FE == 6 & PID_who == 360005
replace type_voted = 2 if countryelection_FE == 6 & IMD3002_LH_DC == 360005
replace type_PID = 2 if countryelection_FE == 6 & PID_who == 360005

replace party_voted = 227 if countryelection_FE == 6 & IMD3002_LH_DC == 360008 //* One Nation Party
replace party_PID = 227 if countryelection_FE == 6 & PID_who == 360008
replace type_voted = 7 if countryelection_FE == 6 & IMD3002_LH_DC == 360008
replace type_PID = 7 if countryelection_FE == 6 & PID_who == 360008

replace party_voted = 228 if countryelection_FE == 6 & IMD3002_LH_DC == 360009 | countryelection_FE == 6 & IMD3002_LH_DC == 360019 //* Christian Democratic Party
replace party_PID = 228 if countryelection_FE == 6 & PID_who == 360009 | countryelection_FE == 6 & PID_who == 360019
replace type_voted = 3 if countryelection_FE == 6 & IMD3002_LH_DC == 360009 | countryelection_FE == 6 & IMD3002_LH_DC == 360019
replace type_PID = 3 if countryelection_FE == 6 & PID_who == 360009 | countryelection_FE == 6 & PID_who == 360019

replace party_voted = 229 if countryelection_FE == 6 & IMD3002_LH_DC == 360010 //* Sex Party
replace party_PID = 229 if countryelection_FE == 6 & PID_who == 360010
replace type_voted = 2 if countryelection_FE == 6 & IMD3002_LH_DC == 360010
replace type_PID = 2 if countryelection_FE == 6 & PID_who == 360010

replace party_voted = 230 if countryelection_FE == 6 & IMD3002_LH_DC == 360011 //* Family First
replace party_PID = 230 if countryelection_FE == 6 & PID_who == 360011
replace type_voted = 3 if countryelection_FE == 6 & IMD3002_LH_DC == 360011
replace type_PID = 3 if countryelection_FE == 6 & PID_who == 360011

replace party_voted = 231 if countryelection_FE == 6 & IMD3002_LH_DC == 360012 //* Katter's Australia Party (Ambiguous ideology, some LW policies but big donor from energy and guns industries)
replace party_PID = 231 if countryelection_FE == 6 & PID_who == 360012
replace type_voted = 7 if countryelection_FE == 6 & IMD3002_LH_DC == 360012
replace type_PID = 7 if countryelection_FE == 6 & PID_who == 360012

replace party_voted = 232 if countryelection_FE == 6 & IMD3002_LH_DC == 360013 //* Palmer UTD Party
replace party_PID = 232 if countryelection_FE == 6 & PID_who == 360013
replace type_voted = 3 if countryelection_FE == 6 & IMD3002_LH_DC == 360013
replace type_PID = 3 if countryelection_FE == 6 & PID_who == 360013

replace party_voted = 233 if countryelection_FE == 6 & IMD3002_LH_DC == 360014 //* Citizen Electoral Council
replace party_PID = 233 if countryelection_FE == 6 & PID_who == 360014
replace type_voted = 7 if countryelection_FE == 6 & IMD3002_LH_DC == 360014
replace type_PID = 7 if countryelection_FE == 6 & PID_who == 360014

replace party_voted = 234 if countryelection_FE == 6 & IMD3002_LH_DC == 360016 //* Motoring Enthusiasts Party
replace party_PID = 234 if countryelection_FE == 6 & PID_who == 360016
replace type_voted = 3 if countryelection_FE == 6 & IMD3002_LH_DC == 360016
replace type_PID = 3 if countryelection_FE == 6 & PID_who == 360016

replace party_voted = 235 if countryelection_FE == 6 & IMD3002_LH_DC == 360017 //* Fishing Party
replace party_PID = 235 if countryelection_FE == 6 & PID_who == 360017
replace type_voted = 3 if countryelection_FE == 6 & IMD3002_LH_DC == 360017
replace type_PID = 3 if countryelection_FE == 6 & PID_who == 360017

replace party_voted = 236 if countryelection_FE == 6 & IMD3002_LH_DC == 360018 //* Wikileaks Party
replace party_PID = 236 if countryelection_FE == 6 & PID_who == 360018
replace type_voted = 2 if countryelection_FE == 6 & IMD3002_LH_DC == 360018
replace type_PID = 2 if countryelection_FE == 6 & PID_who == 360018

replace party_voted = 312 if countryelection_FE == 6 & IMD3002_LH_DC == 360007 //* LibDem Australia
replace party_PID = 312 if countryelection_FE == 6 & PID_who == 360007
replace type_voted = 3 if countryelection_FE == 6 & IMD3002_LH_DC == 360007
replace type_PID = 3 if countryelection_FE == 6 & PID_who == 360007

replace party_voted = 313 if countryelection_FE == 6 & IMD3002_LH_DC == 360015 //* Shooters
replace party_PID = 313 if countryelection_FE == 6 & PID_who == 360015
replace type_voted = 3 if countryelection_FE == 6 & IMD3002_LH_DC == 360015
replace type_PID = 3 if countryelection_FE == 6 & PID_who == 360015


//* Austria 2008

replace incumbent_voted = 1 if countryelection_FE == 7 & IMD3002_LH_PL == 400001 | countryelection_FE == 7 & IMD3002_LH_PL ==  400002  //* Labour
replace incumbent_PID = 1 if countryelection_FE == 7 & PID_who == 400001 | countryelection_FE == 7 & PID_who == 400002 //* Labour

replace party_voted = 1 if countryelection_FE == 7 & IMD3002_LH_PL == 400001 //* SPO
replace party_PID = 1 if countryelection_FE == 7 & PID_who == 400001
replace type_voted = 1 if countryelection_FE == 7 & IMD3002_LH_PL == 400001
replace type_PID = 1 if countryelection_FE == 7 & PID_who == 400001

replace party_voted = 2 if countryelection_FE == 7 & IMD3002_LH_PL == 400002  //* OVP
replace party_PID = 2 if countryelection_FE == 7 & PID_who == 400002 
replace type_voted = 1 if countryelection_FE == 7 & IMD3002_LH_PL == 400002 
replace type_PID = 1 if countryelection_FE == 7 & PID_who == 400002 

replace party_voted = 3 if countryelection_FE == 7 & IMD3002_LH_PL == 400003  //* FPO
replace party_PID = 3 if countryelection_FE == 7 & PID_who == 400003 
replace type_voted = 7 if countryelection_FE == 7 & IMD3002_LH_PL == 400003 
replace type_PID = 7 if countryelection_FE == 7 & PID_who == 400003 

replace party_voted = 4 if countryelection_FE == 7 & IMD3002_LH_PL == 400004  //* BZO
replace party_PID = 4 if countryelection_FE == 7 & PID_who == 400004 
replace type_voted = 5 if countryelection_FE == 7 & IMD3002_LH_PL == 400004 
replace type_PID = 5 if countryelection_FE == 7 & PID_who == 400004 

replace party_voted = 5 if countryelection_FE == 7 & IMD3002_LH_PL == 400005  //* Greens
replace party_PID = 5 if countryelection_FE == 7 & PID_who == 400005 
replace type_voted = 2 if countryelection_FE == 7 & IMD3002_LH_PL == 400005 
replace type_PID = 2 if countryelection_FE == 7 & PID_who == 400005 

replace party_voted = 7 if countryelection_FE == 7 & IMD3002_LH_PL == 400007 //* Lib Forum
replace party_PID = 7 if countryelection_FE == 7 & PID_who == 400007
replace type_voted = 1 if countryelection_FE == 7 & IMD3002_LH_PL == 400007 
replace type_PID = 1 if countryelection_FE == 7 & PID_who == 400007

replace party_voted = 11 if countryelection_FE == 7 & IMD3002_LH_PL == 400013 //* Citizen's List
replace party_PID = 11 if countryelection_FE == 7 & PID_who == 400013
replace type_voted = 2 if countryelection_FE == 7 & IMD3002_LH_PL == 400013 
replace type_PID = 2 if countryelection_FE == 7 & PID_who == 400013

replace party_voted = 314 if countryelection_FE == 7 & IMD3002_LH_PL == 400011 //* Pirate Party
replace party_PID = 314 if countryelection_FE == 7 & PID_who == 400011
replace type_voted = 6 if countryelection_FE == 7 & IMD3002_LH_PL == 400011 
replace type_PID = 6 if countryelection_FE == 7 & PID_who == 400011

//* Austria 2013

replace incumbent_voted = 1 if countryelection_FE == 8 & IMD3002_LH_PL == 400001 | countryelection_FE == 8 & IMD3002_LH_PL ==  400002  //* Labour
replace incumbent_PID = 1 if countryelection_FE == 8 & PID_who == 400001 | countryelection_FE == 8 & PID_who == 400002 //* Labour

replace party_voted = 1 if countryelection_FE == 8 & IMD3002_LH_PL == 400001 //* SPO
replace party_PID = 1 if countryelection_FE == 8 & PID_who == 400001
replace type_voted = 1 if countryelection_FE == 8 & IMD3002_LH_PL == 400001
replace type_PID = 1 if countryelection_FE == 8 & PID_who == 400001

replace party_voted = 2 if countryelection_FE == 8 & IMD3002_LH_PL == 400002  //* OVP
replace party_PID = 2 if countryelection_FE == 8 & PID_who == 400002 
replace type_voted = 1 if countryelection_FE == 8 & IMD3002_LH_PL == 400002 
replace type_PID = 1 if countryelection_FE == 8 & PID_who == 400002 

replace party_voted = 3 if countryelection_FE == 8 & IMD3002_LH_PL == 400003  //* FPO
replace party_PID = 3 if countryelection_FE == 8 & PID_who == 400003 
replace type_voted = 7 if countryelection_FE == 8 & IMD3002_LH_PL == 400003 
replace type_PID = 7 if countryelection_FE == 8 & PID_who == 400003 

replace party_voted = 4 if countryelection_FE == 8 & IMD3002_LH_PL == 400004  //* BZO
replace party_PID = 4 if countryelection_FE == 8 & PID_who == 400004 
replace type_voted = 5 if countryelection_FE == 8 & IMD3002_LH_PL == 400004 
replace type_PID = 5 if countryelection_FE == 8 & PID_who == 400004 

replace party_voted = 5 if countryelection_FE == 8 & IMD3002_LH_PL == 400005  //* Greens
replace party_PID = 5 if countryelection_FE == 8 & PID_who == 400005 
replace type_voted = 2 if countryelection_FE == 8 & IMD3002_LH_PL == 400005 
replace type_PID = 2 if countryelection_FE == 8 & PID_who == 400005 

replace party_voted = 6 if countryelection_FE == 8 & IMD3002_LH_PL == 400006  //* Austrian Communists
replace party_PID = 6 if countryelection_FE == 8 & PID_who == 400006 
replace type_voted = 6 if countryelection_FE == 8 & IMD3002_LH_PL == 400006 
replace type_PID = 6 if countryelection_FE == 8 & PID_who == 400006 

replace party_voted = 7 if countryelection_FE == 8 & IMD3002_LH_PL == 400007 //* Lib Forum
replace party_PID = 7 if countryelection_FE == 8 & PID_who == 400007
replace type_voted = 1 if countryelection_FE == 8 & IMD3002_LH_PL == 400007 
replace type_PID = 1 if countryelection_FE == 8 & PID_who == 400007

replace party_voted = 8 if countryelection_FE == 8 & IMD3002_LH_PL == 400010 //* NEOS
replace party_PID = 8 if countryelection_FE == 8 & PID_who == 400010
replace type_voted = 2 if countryelection_FE == 8 & IMD3002_LH_PL == 400010 
replace type_PID = 2 if countryelection_FE == 8 & PID_who == 400010

replace party_voted = 9 if countryelection_FE == 8 & IMD3002_LH_PL == 400012 //* Team Stronach
replace party_PID = 9 if countryelection_FE == 8 & PID_who == 400012
replace type_voted = 7 if countryelection_FE == 8 & IMD3002_LH_PL == 400012 
replace type_PID = 7 if countryelection_FE == 8 & PID_who == 400012

replace party_voted = 11 if countryelection_FE == 8 & IMD3002_LH_PL == 400013 |  countryelection_FE == 8 & IMD3002_LH_PL == 400015 //* Citizen's List
replace party_PID = 11 if countryelection_FE == 8 & PID_who == 400013 | countryelection_FE == 8 & PID_who == 400015
replace type_voted = 2 if countryelection_FE == 8 & IMD3002_LH_PL == 400013 |  countryelection_FE == 8 & IMD3002_LH_PL == 400015 
replace type_PID = 2 if countryelection_FE == 8 & PID_who == 400013 | countryelection_FE == 8 & PID_who == 400015

replace party_voted = 314 if countryelection_FE == 8 & IMD3002_LH_PL == 400011 //* Pirate Party
replace party_PID = 314 if countryelection_FE == 8 & PID_who == 400011
replace type_voted = 6 if countryelection_FE == 8 & IMD3002_LH_PL == 400011 
replace type_PID = 6 if countryelection_FE == 8 & PID_who == 400011

//* Flanders 1999

replace incumbent_voted = 1 if countryelection_FE == 9 & IMD3002_LH_PL == 560003 | countryelection_FE == 9 & IMD3002_LH_PL ==  560005  | countryelection_FE == 9 & IMD3002_LH_PL ==  560021 //* Christ Dem and Socs
replace incumbent_PID = 1 if countryelection_FE == 9 & PID_who == 560003 | countryelection_FE == 9 & PID_who == 560005 | countryelection_FE == 9 & PID_who ==  560021 //* Christ Dem and Socs

replace party_voted = 14 if countryelection_FE == 9 & IMD3002_LH_PL == 560003 | countryelection_FE == 9 & IMD3002_LH_PL ==  560021 //* ChristDems
replace party_PID = 14 if countryelection_FE == 9 & PID_who == 560003 | countryelection_FE == 9 & PID_who ==  560021
replace type_voted = 1 if countryelection_FE == 9 & IMD3002_LH_PL == 560003 | countryelection_FE == 9 & IMD3002_LH_PL ==  560021
replace type_PID = 1 if countryelection_FE == 9 & PID_who == 560003 | countryelection_FE == 9 & PID_who ==  560021

replace party_voted = 15 if countryelection_FE == 9 & IMD3002_LH_PL == 560004 | countryelection_FE == 9 & IMD3002_LH_PL == 560016 //* Liberals
replace party_PID = 15 if countryelection_FE == 9 & PID_who == 560004   |  countryelection_FE == 9 & PID_who == 560016
replace type_voted = 1 if countryelection_FE == 9 & IMD3002_LH_PL == 560004  | countryelection_FE == 9 & IMD3002_LH_PL == 560016
replace type_PID = 1 if countryelection_FE == 9 & PID_who == 560004  |  countryelection_FE == 9 & PID_who == 560016

replace party_voted = 16 if countryelection_FE == 9 & IMD3002_LH_PL == 560005 | countryelection_FE == 9 & IMD3002_LH_PL == 560002 //* Socialists
replace party_PID = 16 if countryelection_FE == 9 & PID_who == 560005  | countryelection_FE == 9 & PID_who == 560002
replace type_voted = 1 if countryelection_FE == 9 & IMD3002_LH_PL == 560005 | countryelection_FE == 9 & IMD3002_LH_PL == 560002
replace type_PID = 1 if countryelection_FE == 9 & PID_who == 560005 | countryelection_FE == 9 & PID_who == 560002

replace party_voted = 18 if countryelection_FE == 9 & IMD3002_LH_PL == 560012 //* Flemish Bloc
replace party_PID = 18 if countryelection_FE == 9 & PID_who == 560012 
replace type_voted = 7 if countryelection_FE == 9 & IMD3002_LH_PL == 560012
replace type_PID = 7 if countryelection_FE == 9 & PID_who == 560012

replace party_voted = 23 if countryelection_FE == 9 & IMD3002_LH_PL == 560018 | countryelection_FE == 9 & IMD3002_LH_PL == 560013 //* Flemish Greens
replace party_PID = 23 if countryelection_FE == 9 & PID_who == 560018 | countryelection_FE == 9 & PID_who == 560013
replace type_voted = 2 if countryelection_FE == 9 & IMD3002_LH_PL == 560018 | countryelection_FE == 9 & IMD3002_LH_PL == 560013
replace type_PID = 2 if countryelection_FE == 9 & PID_who == 560018 | countryelection_FE == 9 & PID_who == 560013

replace party_voted = 20 if countryelection_FE == 9 & IMD3002_LH_PL == 560015 //* People's Union
replace party_PID = 20 if countryelection_FE == 9 & PID_who == 560015 
replace type_voted = 1 if countryelection_FE == 9 & IMD3002_LH_PL == 560015
replace type_PID = 1 if countryelection_FE == 9 & PID_who == 560015

replace party_voted = 20 if countryelection_FE == 9 & IMD3002_LH_PL == 560011 //* Workers' Party of Belgium
replace party_PID = 20 if countryelection_FE == 9 & PID_who == 560011
replace type_voted = 6 if countryelection_FE == 9 & IMD3002_LH_PL == 560011
replace type_PID = 6 if countryelection_FE == 9 & PID_who == 560011

replace party_voted = 27 if countryelection_FE == 9 & IMD3002_LH_PL == 560023 //* LIVRE
replace party_PID = 27 if countryelection_FE == 9 & PID_who == 560023 
replace type_voted = 2 if countryelection_FE == 9 & IMD3002_LH_PL == 560023
replace type_PID = 2 if countryelection_FE == 9 & PID_who == 560023




//* Wallonia 1999

replace incumbent_voted = 1 if countryelection_FE == 10 & IMD3002_LH_PL == 560002 | countryelection_FE == 10 & IMD3002_LH_PL ==  560003  | countryelection_FE == 10 & IMD3002_LH_PL ==  560005 | countryelection_FE == 10 & IMD3002_LH_PL ==  560021 //* Christ Dem and Socs
replace incumbent_PID = 1 if countryelection_FE == 10 & PID_who == 560002 | countryelection_FE == 10 & PID_who == 560003 | countryelection_FE == 10 & PID_who ==  560005 | countryelection_FE == 10 & PID_who ==  560021 //* Christ Dem and Socs

replace party_voted = 13 if countryelection_FE == 10 & IMD3002_LH_PL == 560002 | countryelection_FE == 10 & IMD3002_LH_PL ==  560005 //* Socialists
replace party_PID = 13 if countryelection_FE == 10 & PID_who == 560002 | countryelection_FE == 10 & PID_who ==  560005
replace type_voted = 1 if countryelection_FE == 10 & IMD3002_LH_PL == 560002 | countryelection_FE == 10 & IMD3002_LH_PL ==  560005
replace type_PID = 1 if countryelection_FE == 10 & PID_who == 560002 | countryelection_FE == 10 & PID_who ==  560005

replace party_voted = 17 if countryelection_FE == 10 & IMD3002_LH_PL == 560003 | countryelection_FE == 10 & IMD3002_LH_PL == 560021 //* ChristDem
replace party_PID = 17 if countryelection_FE == 10 & PID_who == 560003  | countryelection_FE == 10 & PID_who == 560021
replace type_voted = 1 if countryelection_FE == 10 & IMD3002_LH_PL == 560003  | countryelection_FE == 10 & IMD3002_LH_PL == 560021 
replace type_PID = 1 if countryelection_FE == 10 & PID_who == 560003  | countryelection_FE == 10 & PID_who == 560021 

replace party_voted = 21 if countryelection_FE == 10 & IMD3002_LH_PL == 560004 | countryelection_FE == 10 & IMD3002_LH_PL == 560016 //* Liberals
replace party_PID = 21 if countryelection_FE == 10 & PID_who == 560004 | countryelection_FE == 10 & PID_who == 560016
replace type_voted = 1 if countryelection_FE == 10 & IMD3002_LH_PL == 560004 | countryelection_FE == 10 & IMD3002_LH_PL == 560016
replace type_PID = 1 if countryelection_FE == 10 & PID_who == 560004  | countryelection_FE == 10 & PID_who == 560016

replace party_voted = 24 if countryelection_FE == 10 & IMD3002_LH_PL == 560019 //* National Front
replace party_PID = 24 if countryelection_FE == 10 & PID_who == 560019 
replace type_voted = 7 if countryelection_FE == 10 & IMD3002_LH_PL == 560019
replace type_PID = 7 if countryelection_FE == 10 & PID_who == 560019

replace party_voted = 19 if countryelection_FE == 10 & IMD3002_LH_PL == 560013 | countryelection_FE == 10 & IMD3002_LH_PL == 560018 //* Greens
replace party_PID = 19 if countryelection_FE == 10 & PID_who == 560013 | countryelection_FE == 10 & PID_who == 560018
replace type_voted = 2 if countryelection_FE == 10 & IMD3002_LH_PL == 560013 | countryelection_FE == 10 & IMD3002_LH_PL == 560018
replace type_PID = 2 if countryelection_FE == 10 & PID_who == 560013 | countryelection_FE == 10 & PID_who == 560018 

replace party_voted = 20 if countryelection_FE == 10 & IMD3002_LH_PL == 560015 //* People's Union
replace party_PID = 20 if countryelection_FE == 10 & PID_who == 560015 
replace type_voted = 1 if countryelection_FE == 10 & IMD3002_LH_PL == 560015
replace type_PID = 1 if countryelection_FE == 10 & PID_who == 560015

replace party_voted = 27 if countryelection_FE == 10 & IMD3002_LH_PL == 560023 //* LIVRE
replace party_PID = 27 if countryelection_FE == 10 & PID_who == 560023 
replace type_voted = 2 if countryelection_FE == 10 & IMD3002_LH_PL == 560023
replace type_PID = 2 if countryelection_FE == 10 & PID_who == 560023



//* Belgium 2003

replace incumbent_voted = 1 if countryelection_FE == 11 & IMD3002_LH_PL == 560002 | countryelection_FE == 11 & IMD3002_LH_PL ==  560003  | countryelection_FE == 11 & IMD3002_LH_PL ==  560005 | countryelection_FE == 11 & IMD3002_LH_PL ==  560021 //* Christ Dem and Socs
replace incumbent_PID = 1 if countryelection_FE == 11 & PID_who == 560002 | countryelection_FE == 11 & PID_who == 560003 | countryelection_FE == 11 & PID_who ==  560005 | countryelection_FE == 11 & PID_who ==  560021 //* Christ Dem and Socs

replace party_voted = 12 if countryelection_FE == 11 & IMD3002_LH_PL == 560001 //* NVA
replace party_PID = 12 if countryelection_FE == 11 & PID_who == 560001 
replace type_voted = 7 if countryelection_FE == 11 & IMD3002_LH_PL == 560001
replace type_PID = 7 if countryelection_FE == 11 & PID_who == 560001

replace party_voted = 13 if countryelection_FE == 11 & IMD3002_LH_PL == 560002  //* Socialists (W)
replace party_PID = 13 if countryelection_FE == 11 & PID_who == 560002 
replace type_voted = 1 if countryelection_FE == 11 & IMD3002_LH_PL == 560002 
replace type_PID = 1 if countryelection_FE == 11 & PID_who == 560002 

replace party_voted = 16 if countryelection_FE == 11 & IMD3002_LH_PL == 560005 //* Socialists (F)
replace party_PID = 16 if countryelection_FE == 11 & PID_who == 560005
replace type_voted = 1 if countryelection_FE == 11 & IMD3002_LH_PL == 560005
replace type_PID = 1 if countryelection_FE == 11 & PID_who == 560005 

replace party_voted = 14 if countryelection_FE == 11 & IMD3002_LH_PL == 560003  //* ChristDem (F)
replace party_PID = 14 if countryelection_FE == 11 & PID_who == 560003 
replace type_voted = 1 if countryelection_FE == 11 & IMD3002_LH_PL == 560003 
replace type_PID = 1 if countryelection_FE == 11 & PID_who == 560003 

replace party_voted = 17 if countryelection_FE == 11 & IMD3002_LH_PL == 560010 //* Christ Dem (W)
replace party_PID = 17 if countryelection_FE == 11 & PID_who == 560010
replace type_voted = 1 if countryelection_FE == 11 & IMD3002_LH_PL == 560010
replace type_PID = 1 if countryelection_FE == 11 & PID_who == 560010 

replace party_voted = 15 if countryelection_FE == 11 & IMD3002_LH_PL == 560004 //* Liberals (F)
replace party_PID = 15 if countryelection_FE == 11 & PID_who == 560004
replace type_voted = 1 if countryelection_FE == 11 & IMD3002_LH_PL == 560004
replace type_PID = 1 if countryelection_FE == 11 & PID_who == 560004 

replace party_voted = 21 if countryelection_FE == 11 & IMD3002_LH_PL == 560026 //* Liberals (W)
replace party_PID = 21 if countryelection_FE == 11 & PID_who == 560026
replace type_voted = 1 if countryelection_FE == 11 & IMD3002_LH_PL == 560026
replace type_PID = 1 if countryelection_FE == 11 & PID_who == 560026 

replace party_voted = 18 if countryelection_FE == 11 & IMD3002_LH_PL == 560012 //* Flemish Bloc
replace party_PID = 18 if countryelection_FE == 11 & PID_who == 560012 
replace type_voted = 7 if countryelection_FE == 11 & IMD3002_LH_PL == 560012
replace type_PID = 7 if countryelection_FE == 11 & PID_who == 560012

replace party_voted = 23 if countryelection_FE == 11 & IMD3002_LH_PL == 560013 //* Greens (F)
replace party_PID = 23 if countryelection_FE == 11 & PID_who == 560013
replace type_voted = 1 if countryelection_FE == 11 & IMD3002_LH_PL == 560013
replace type_PID = 1 if countryelection_FE == 11 & PID_who == 560013 

replace party_voted = 19 if countryelection_FE == 11 & IMD3002_LH_PL == 560018 //* Greens (W)
replace party_PID = 19 if countryelection_FE == 11 & PID_who == 560018
replace type_voted = 1 if countryelection_FE == 11 & IMD3002_LH_PL == 560018
replace type_PID = 1 if countryelection_FE == 11 & PID_who == 560018

replace party_voted = 22 if countryelection_FE == 11 & IMD3002_LH_PL == 560017 //* RESIST
replace party_PID = 22 if countryelection_FE == 11 & PID_who == 560017
replace type_voted = 6 if countryelection_FE == 11 & IMD3002_LH_PL == 560017
replace type_PID = 6 if countryelection_FE == 11 & PID_who == 560017

replace party_voted = 24 if countryelection_FE == 11 & IMD3002_LH_PL == 560019 //* National Front
replace party_PID = 24 if countryelection_FE == 11 & PID_who == 560019
replace type_voted = 7 if countryelection_FE == 11 & IMD3002_LH_PL == 560019
replace type_PID = 7 if countryelection_FE == 11 & PID_who == 560019

replace party_voted = 25 if countryelection_FE == 11 & IMD3002_LH_PL == 560020 //* Workers' Party
replace party_PID = 25 if countryelection_FE == 11 & PID_who == 560020
replace type_voted = 6 if countryelection_FE == 11 & IMD3002_LH_PL == 560020
replace type_PID = 6 if countryelection_FE == 11 & PID_who == 560020

replace party_voted = 27 if countryelection_FE == 11 & IMD3002_LH_PL == 560023 //* LIVRE/VIVANT
replace party_PID = 27 if countryelection_FE == 11 & PID_who == 560023
replace type_voted = 2 if countryelection_FE == 11 & IMD3002_LH_PL == 560023
replace type_PID = 2 if countryelection_FE == 11 & PID_who == 560023

replace party_voted = 20 if countryelection_FE == 11 & IMD3002_LH_PL == 560015 //* People's Union
replace party_PID = 20 if countryelection_FE == 11 & PID_who == 560015 
replace type_voted = 1 if countryelection_FE == 11 & IMD3002_LH_PL == 560015
replace type_PID = 1 if countryelection_FE == 11 & PID_who == 560015

//* Canada 1997 

replace incumbent_voted = 1 if countryelection_FE == 20 & IMD3002_LH_DC == 1240001 //* Libs
replace incumbent_PID = 1 if countryelection_FE == 20 & PID_who == 1240001

replace party_voted = 238 if countryelection_FE == 20 & IMD3002_LH_DC == 1240001 //* Canadian Liberals
replace party_PID = 238 if countryelection_FE == 20 & PID_who == 1240001
replace type_voted = 1 if countryelection_FE == 20 & IMD3002_LH_DC == 1240001
replace type_PID = 1 if countryelection_FE == 20 & PID_who == 1240001

replace party_voted = 240 if countryelection_FE == 20 & IMD3002_LH_DC == 1240003 //* NDP
replace party_PID = 240 if countryelection_FE == 20 & PID_who == 1240003
replace type_voted = 1 if countryelection_FE == 20 & IMD3002_LH_DC == 1240003
replace type_PID = 1 if countryelection_FE == 20 & PID_who == 1240003

replace party_voted = 241 if countryelection_FE == 20 & IMD3002_LH_DC == 1240004 //* Bloc Quebec
replace party_PID = 241 if countryelection_FE == 20 & PID_who == 1240004
replace type_voted = 6 if countryelection_FE == 20 & IMD3002_LH_DC == 1240004
replace type_PID = 6 if countryelection_FE == 20 & PID_who == 1240004

replace party_voted = 243 if countryelection_FE == 20 & IMD3002_LH_DC == 1240006 //* ProgCon
replace party_PID = 243 if countryelection_FE == 20 & PID_who == 1240006
replace type_voted = 1 if countryelection_FE == 20 & IMD3002_LH_DC == 1240006
replace type_PID = 1 if countryelection_FE == 20 & PID_who == 1240006

replace party_voted = 244 if countryelection_FE == 20 & IMD3002_LH_DC == 1240007 //* Reform Party
replace party_PID = 244 if countryelection_FE == 20 & PID_who == 1240007
replace type_voted = 7 if countryelection_FE == 20 & IMD3002_LH_DC == 1240007
replace type_PID = 7 if countryelection_FE == 20 & PID_who == 1240007

replace party_voted = 315 if countryelection_FE == 20 & IMD3002_LH_DC == 1240017 //* Canadian Heritage Party
replace party_PID = 315 if countryelection_FE == 20 & PID_who == 1240017
replace type_voted = 3 if countryelection_FE == 20 & IMD3002_LH_DC == 1240017
replace type_PID = 3 if countryelection_FE == 20 & PID_who == 1240017


//* Canada 2004 

replace incumbent_voted = 1 if countryelection_FE == 21 & IMD3002_LH_DC == 1240001 //* Libs
replace incumbent_PID = 1 if countryelection_FE == 21 & PID_who == 1240001

replace party_voted = 238 if countryelection_FE == 21 & IMD3002_LH_DC == 1240001 //* Canadian Liberals
replace party_PID = 238 if countryelection_FE == 21 & PID_who == 1240001
replace type_voted = 1 if countryelection_FE == 21 & IMD3002_LH_DC == 1240001
replace type_PID = 1 if countryelection_FE == 21 & PID_who == 1240001

replace party_voted = 239 if countryelection_FE == 21 & IMD3002_LH_DC == 1240002 //* Conservative Party
replace party_PID = 239 if countryelection_FE == 21 & PID_who == 1240002
replace type_voted = 1 if countryelection_FE == 21 & IMD3002_LH_DC == 1240002
replace type_PID = 1 if countryelection_FE == 21 & PID_who == 1240002

replace party_voted = 240 if countryelection_FE == 21 & IMD3002_LH_DC == 1240003 //* NDP
replace party_PID = 240 if countryelection_FE == 21 & PID_who == 1240003
replace type_voted = 1 if countryelection_FE == 21 & IMD3002_LH_DC == 1240003
replace type_PID = 1 if countryelection_FE == 21 & PID_who == 1240003

replace party_voted = 241 if countryelection_FE == 21 & IMD3002_LH_DC == 1240004 //* Bloc Quebec
replace party_PID = 241 if countryelection_FE == 21 & PID_who == 1240004
replace type_voted = 6 if countryelection_FE == 21 & IMD3002_LH_DC == 1240004
replace type_PID = 6 if countryelection_FE == 21 & PID_who == 1240004

replace party_voted = 242 if countryelection_FE == 21 & IMD3002_LH_DC == 1240005 //* Greens
replace party_PID = 242 if countryelection_FE == 21 & PID_who == 1240005
replace type_voted = 2 if countryelection_FE == 21 & IMD3002_LH_DC == 1240005
replace type_PID = 2 if countryelection_FE == 21 & PID_who == 1240005

replace party_voted = 243 if countryelection_FE == 21 & IMD3002_LH_DC == 1240006 //* ProgCon
replace party_PID = 243 if countryelection_FE == 21 & PID_who == 1240006
replace type_voted = 1 if countryelection_FE == 21 & IMD3002_LH_DC == 1240006
replace type_PID = 1 if countryelection_FE == 21 & PID_who == 1240006

replace party_voted = 244 if countryelection_FE == 21 & IMD3002_LH_DC == 1240007 //* Reform Party
replace party_PID = 244 if countryelection_FE == 21 & PID_who == 1240007
replace type_voted = 7 if countryelection_FE == 21 & IMD3002_LH_DC == 1240007
replace type_PID = 7 if countryelection_FE == 21 & PID_who == 1240007

replace party_voted = 245 if countryelection_FE == 21 & IMD3002_LH_DC == 1240015 //* Marijuana Party
replace party_PID = 245 if countryelection_FE == 21 & PID_who == 1240015
replace type_voted = 2 if countryelection_FE == 21 & IMD3002_LH_DC == 1240015
replace type_PID = 2 if countryelection_FE == 21 & PID_who == 1240015

replace party_voted = 315 if countryelection_FE == 21 & IMD3002_LH_DC == 1240017 //* Canadian Heritage Party
replace party_PID = 315 if countryelection_FE == 21 & PID_who == 1240017
replace type_voted = 3 if countryelection_FE == 21 & IMD3002_LH_DC == 1240017
replace type_PID = 3 if countryelection_FE == 21 & PID_who == 1240017

//* Canada 2008 

replace incumbent_voted = 1 if countryelection_FE == 22 & IMD3002_LH_DC == 1240002 //* Cons
replace incumbent_PID = 1 if countryelection_FE == 22 & PID_who == 1240002


replace party_voted = 238 if countryelection_FE == 22 & IMD3002_LH_DC == 1240001 //* Canadian Liberals
replace party_PID = 238 if countryelection_FE == 22 & PID_who == 1240001
replace type_voted = 1 if countryelection_FE == 22 & IMD3002_LH_DC == 1240001
replace type_PID = 1 if countryelection_FE == 22 & PID_who == 1240001

replace party_voted = 239 if countryelection_FE == 22 & IMD3002_LH_DC == 1240002 //* Conservative Party
replace party_PID = 239 if countryelection_FE == 22 & PID_who == 1240002
replace type_voted = 1 if countryelection_FE == 22 & IMD3002_LH_DC == 1240002
replace type_PID = 1 if countryelection_FE == 22 & PID_who == 1240002

replace party_voted = 240 if countryelection_FE == 22 & IMD3002_LH_DC == 1240003 //* NDP
replace party_PID = 240 if countryelection_FE == 22 & PID_who == 1240003
replace type_voted = 1 if countryelection_FE == 22 & IMD3002_LH_DC == 1240003
replace type_PID = 1 if countryelection_FE == 22 & PID_who == 1240003

replace party_voted = 241 if countryelection_FE == 22 & IMD3002_LH_DC == 1240004 //* Bloc Quebec
replace party_PID = 241 if countryelection_FE == 22 & PID_who == 1240004
replace type_voted = 6 if countryelection_FE == 22 & IMD3002_LH_DC == 1240004
replace type_PID = 6 if countryelection_FE == 22 & PID_who == 1240004

replace party_voted = 242 if countryelection_FE == 22 & IMD3002_LH_DC == 1240005 //* Greens
replace party_PID = 242 if countryelection_FE == 22 & PID_who == 1240005
replace type_voted = 2 if countryelection_FE == 22 & IMD3002_LH_DC == 1240005
replace type_PID = 2 if countryelection_FE == 22 & PID_who == 1240005

replace party_voted = 243 if countryelection_FE == 22 & IMD3002_LH_DC == 1240006 //* ProgCon
replace party_PID = 243 if countryelection_FE == 22 & PID_who == 1240006
replace type_voted = 1 if countryelection_FE == 22 & IMD3002_LH_DC == 1240006
replace type_PID = 1 if countryelection_FE == 22 & PID_who == 1240006

replace party_voted = 244 if countryelection_FE == 22 & IMD3002_LH_DC == 1240007 //* Reform Party
replace party_PID = 244 if countryelection_FE == 22 & PID_who == 1240007
replace type_voted = 7 if countryelection_FE == 22 & IMD3002_LH_DC == 1240007
replace type_PID = 7 if countryelection_FE == 22 & PID_who == 1240007

replace party_voted = 245 if countryelection_FE == 22 & IMD3002_LH_DC == 1240015 //* Marijuana Party
replace party_PID = 245 if countryelection_FE == 22 & PID_who == 1240015
replace type_voted = 2 if countryelection_FE == 22 & IMD3002_LH_DC == 1240015
replace type_PID = 2 if countryelection_FE == 22 & PID_who == 1240015

replace party_voted = 315 if countryelection_FE == 22 & IMD3002_LH_DC == 1240017 //* Canadian Heritage Party
replace party_PID = 315 if countryelection_FE == 22 & PID_who == 1240017
replace type_voted = 3 if countryelection_FE == 22 & IMD3002_LH_DC == 1240017
replace type_PID = 3 if countryelection_FE == 22 & PID_who == 1240017

//* Canada 2011 

replace incumbent_voted = 1 if countryelection_FE == 23 & IMD3002_LH_DC == 1240002 //* Cons
replace incumbent_PID = 1 if countryelection_FE == 23 & PID_who == 1240002


replace party_voted = 238 if countryelection_FE == 23 & IMD3002_LH_DC == 1240001 //* Canadian Liberals
replace party_PID = 238 if countryelection_FE == 23 & PID_who == 1240001
replace type_voted = 1 if countryelection_FE == 23 & IMD3002_LH_DC == 1240001
replace type_PID = 1 if countryelection_FE == 23 & PID_who == 1240001

replace party_voted = 239 if countryelection_FE == 23 & IMD3002_LH_DC == 1240002 //* Conservative Party
replace party_PID = 239 if countryelection_FE == 23 & PID_who == 1240002
replace type_voted = 1 if countryelection_FE == 23 & IMD3002_LH_DC == 1240002
replace type_PID = 1 if countryelection_FE == 23 & PID_who == 1240002

replace party_voted = 240 if countryelection_FE == 23 & IMD3002_LH_DC == 1240003 //* NDP
replace party_PID = 240 if countryelection_FE == 23 & PID_who == 1240003
replace type_voted = 1 if countryelection_FE == 23 & IMD3002_LH_DC == 1240003
replace type_PID = 1 if countryelection_FE == 23 & PID_who == 1240003

replace party_voted = 241 if countryelection_FE == 23 & IMD3002_LH_DC == 1240004 //* Bloc Quebec
replace party_PID = 241 if countryelection_FE == 23 & PID_who == 1240004
replace type_voted = 6 if countryelection_FE == 23 & IMD3002_LH_DC == 1240004
replace type_PID = 6 if countryelection_FE == 23 & PID_who == 1240004

replace party_voted = 242 if countryelection_FE == 23 & IMD3002_LH_DC == 1240005 //* Greens
replace party_PID = 242 if countryelection_FE == 23 & PID_who == 1240005
replace type_voted = 2 if countryelection_FE == 23 & IMD3002_LH_DC == 1240005
replace type_PID = 2 if countryelection_FE == 23 & PID_who == 1240005

replace party_voted = 243 if countryelection_FE == 23 & IMD3002_LH_DC == 1240006 //* ProgCon
replace party_PID = 243 if countryelection_FE == 23 & PID_who == 1240006
replace type_voted = 1 if countryelection_FE == 23 & IMD3002_LH_DC == 1240006
replace type_PID = 1 if countryelection_FE == 23 & PID_who == 1240006

replace party_voted = 244 if countryelection_FE == 23 & IMD3002_LH_DC == 1240007 //* Reform Party
replace party_PID = 244 if countryelection_FE == 23 & PID_who == 1240007
replace type_voted = 7 if countryelection_FE == 23 & IMD3002_LH_DC == 1240007
replace type_PID = 7 if countryelection_FE == 23 & PID_who == 1240007

replace party_voted = 245 if countryelection_FE == 23 & IMD3002_LH_DC == 1240015 //* Marijuana Party
replace party_PID = 245 if countryelection_FE == 23 & PID_who == 1240015
replace type_voted = 2 if countryelection_FE == 23 & IMD3002_LH_DC == 1240015
replace type_PID = 2 if countryelection_FE == 23 & PID_who == 1240015

replace party_voted = 315 if countryelection_FE == 23 & IMD3002_LH_DC == 1240017 //* Canadian Heritage Party
replace party_PID = 315 if countryelection_FE == 23 & PID_who == 1240017
replace type_voted = 3 if countryelection_FE == 23 & IMD3002_LH_DC == 1240017
replace type_PID = 3 if countryelection_FE == 23 & PID_who == 1240017

//* Canada 2015

replace incumbent_voted = 1 if countryelection_FE == 24 & IMD3002_LH_DC == 1240002 //* Cons
replace incumbent_PID = 1 if countryelection_FE == 24 & PID_who == 1240002


replace party_voted = 238 if countryelection_FE == 24 & IMD3002_LH_DC == 1240001 //* Canadian Liberals
replace party_PID = 238 if countryelection_FE == 24 & PID_who == 1240001
replace type_voted = 1 if countryelection_FE == 24 & IMD3002_LH_DC == 1240001
replace type_PID = 1 if countryelection_FE == 24 & PID_who == 1240001

replace party_voted = 239 if countryelection_FE == 24 & IMD3002_LH_DC == 1240002 //* Conservative Party
replace party_PID = 239 if countryelection_FE == 24 & PID_who == 1240002
replace type_voted = 1 if countryelection_FE == 24 & IMD3002_LH_DC == 1240002
replace type_PID = 1 if countryelection_FE == 24 & PID_who == 1240002

replace party_voted = 240 if countryelection_FE == 24 & IMD3002_LH_DC == 1240003 //* NDP
replace party_PID = 240 if countryelection_FE == 24 & PID_who == 1240003
replace type_voted = 1 if countryelection_FE == 24 & IMD3002_LH_DC == 1240003
replace type_PID = 1 if countryelection_FE == 24 & PID_who == 1240003

replace party_voted = 241 if countryelection_FE == 24 & IMD3002_LH_DC == 1240004 //* Bloc Quebec
replace party_PID = 241 if countryelection_FE == 24 & PID_who == 1240004
replace type_voted = 6 if countryelection_FE == 24 & IMD3002_LH_DC == 1240004
replace type_PID = 6 if countryelection_FE == 24 & PID_who == 1240004

replace party_voted = 242 if countryelection_FE == 24 & IMD3002_LH_DC == 1240005 //* Greens
replace party_PID = 242 if countryelection_FE == 24 & PID_who == 1240005
replace type_voted = 2 if countryelection_FE == 24 & IMD3002_LH_DC == 1240005
replace type_PID = 2 if countryelection_FE == 24 & PID_who == 1240005

replace party_voted = 243 if countryelection_FE == 24 & IMD3002_LH_DC == 1240006 //* ProgCon
replace party_PID = 243 if countryelection_FE == 24 & PID_who == 1240006
replace type_voted = 1 if countryelection_FE == 24 & IMD3002_LH_DC == 1240006
replace type_PID = 1 if countryelection_FE == 24 & PID_who == 1240006

replace party_voted = 244 if countryelection_FE == 24 & IMD3002_LH_DC == 1240007 //* Reform Party
replace party_PID = 244 if countryelection_FE == 24 & PID_who == 1240007
replace type_voted = 7 if countryelection_FE == 24 & IMD3002_LH_DC == 1240007
replace type_PID = 7 if countryelection_FE == 24 & PID_who == 1240007

replace party_voted = 245 if countryelection_FE == 24 & IMD3002_LH_DC == 1240015 //* Marijuana Party
replace party_PID = 245 if countryelection_FE == 24 & PID_who == 1240015
replace type_voted = 2 if countryelection_FE == 24 & IMD3002_LH_DC == 1240015
replace type_PID = 2 if countryelection_FE == 24 & PID_who == 1240015

replace party_voted = 315 if countryelection_FE == 24 & IMD3002_LH_DC == 1240017 //* Canadian Heritage Party
replace party_PID = 315 if countryelection_FE == 24 & PID_who == 1240017
replace type_voted = 3 if countryelection_FE == 24 & IMD3002_LH_DC == 1240017
replace type_PID = 3 if countryelection_FE == 24 & PID_who == 1240017

//* Switzerland 1999 

replace incumbent_voted = 1 if countryelection_FE == 25 & inlist(IMD3002_LH_PL,7560001,7560002,7560003,7560024,7560020)
replace incumbent_PID = 1 if countryelection_FE == 25 & inlist(PID_who,7560001,7560002,7560003,7560024,7560020)

replace party_voted = 202 if countryelection_FE == 25 & IMD3002_LH_PL == 7560001 //* Swiss People's Party
replace party_PID = 202 if countryelection_FE == 25 & PID_who == 7560001
replace type_voted = 5 if countryelection_FE == 25 & IMD3002_LH_PL == 7560001
replace type_PID = 5 if countryelection_FE == 25 & PID_who == 7560001

replace party_voted = 203 if countryelection_FE == 25 & IMD3002_LH_PL == 7560002 //* Swiss SDP
replace party_PID = 203 if countryelection_FE == 25 & PID_who == 7560002
replace type_voted = 1 if countryelection_FE == 25 & IMD3002_LH_PL == 7560002
replace type_PID = 1 if countryelection_FE == 25 & PID_who == 7560002

replace party_voted = 204 if countryelection_FE == 25 & IMD3002_LH_PL == 7560003 | countryelection_FE == 25 & IMD3002_LH_PL == 7560020   //* Swiss ChristDem
replace party_PID = 204 if countryelection_FE == 25 & PID_who == 7560003 | countryelection_FE == 25 & PID_who == 7560020
replace type_voted = 1 if countryelection_FE == 25 & IMD3002_LH_PL == 7560003 | countryelection_FE == 25 & IMD3002_LH_PL == 7560020
replace type_PID = 1 if countryelection_FE == 25 & PID_who == 7560003 | countryelection_FE == 25 & PID_who == 7560020

replace party_voted = 206 if countryelection_FE == 25 & IMD3002_LH_PL == 7560005 //* Swiss Greens
replace party_PID = 206 if countryelection_FE == 25 & PID_who == 7560005
replace type_voted = 2 if countryelection_FE == 25 & IMD3002_LH_PL == 7560005
replace type_PID = 2 if countryelection_FE == 25 & PID_who == 7560005

replace party_voted = 207 if countryelection_FE == 25 & IMD3002_LH_PL == 7560006 //* Evangelical People's
replace party_PID = 207 if countryelection_FE == 25 & PID_who == 7560006
replace type_voted = 1 if countryelection_FE == 25 & IMD3002_LH_PL == 7560006
replace type_PID = 1 if countryelection_FE == 25 & PID_who == 7560006

replace party_voted = 208 if countryelection_FE == 25 & IMD3002_LH_PL == 7560007 //* Party of Labour
replace party_PID = 208 if countryelection_FE == 25 & PID_who == 7560007
replace type_voted = 6 if countryelection_FE == 25 & IMD3002_LH_PL == 7560007
replace type_PID = 6 if countryelection_FE == 25 & PID_who == 7560007

replace party_voted = 209 if countryelection_FE == 25 & IMD3002_LH_PL == 7560008 //* Ticino League
replace party_PID = 209 if countryelection_FE == 25 & PID_who == 7560008
replace type_voted = 7 if countryelection_FE == 25 & IMD3002_LH_PL == 7560008
replace type_PID = 7 if countryelection_FE == 25 & PID_who == 7560008

replace party_voted = 210 if countryelection_FE == 25 & IMD3002_LH_PL == 7560009 //* Swiss FDU
replace party_PID = 210 if countryelection_FE == 25 & PID_who == 7560009
replace type_voted = 7 if countryelection_FE == 25 & IMD3002_LH_PL == 7560009
replace type_PID = 7 if countryelection_FE == 25 & PID_who == 7560009

replace party_voted = 211 if countryelection_FE == 25 & IMD3002_LH_PL == 7560010 //* Swiss Democrats
replace party_PID = 211 if countryelection_FE == 25 & PID_who == 7560010
replace type_voted = 7 if countryelection_FE == 25 & IMD3002_LH_PL == 7560010
replace type_PID = 7 if countryelection_FE == 25 & PID_who == 7560010

replace party_voted = 212 if countryelection_FE == 25 & IMD3002_LH_PL == 7560012 //* Solidarities
replace party_PID = 212 if countryelection_FE == 25 & PID_who == 7560012
replace type_voted = 6 if countryelection_FE == 25 & IMD3002_LH_PL == 7560012
replace type_PID = 6 if countryelection_FE == 25 & PID_who == 7560012

replace party_voted = 213 if countryelection_FE == 25 & IMD3002_LH_PL == 7560013 //* Swiss Freedom Party
replace party_PID = 213 if countryelection_FE == 25 & PID_who == 7560013
replace type_voted = 7 if countryelection_FE == 25 & IMD3002_LH_PL == 7560013
replace type_PID = 7 if countryelection_FE == 25 & PID_who == 7560013

replace party_voted = 214 if countryelection_FE == 25 & IMD3002_LH_PL == 7560014 //* Liberal Party
replace party_PID = 214 if countryelection_FE == 25 & PID_who == 7560014
replace type_voted = 3 if countryelection_FE == 25 & IMD3002_LH_PL == 7560014
replace type_PID = 3 if countryelection_FE == 25 & PID_who == 7560014

replace party_voted = 215 if countryelection_FE == 25 & IMD3002_LH_PL == 7560015 //* Feminist and Greens
replace party_PID = 215 if countryelection_FE == 25 & PID_who == 7560015
replace type_voted = 6 if countryelection_FE == 25 & IMD3002_LH_PL == 7560015
replace type_PID = 6 if countryelection_FE == 25 & PID_who == 7560015

replace party_voted = 205 if countryelection_FE == 25 & IMD3002_LH_PL == 7560024 //* Radical Democratic Party
replace party_PID = 205 if countryelection_FE == 25 & PID_who == 7560024
replace type_voted = 1 if countryelection_FE == 25 & IMD3002_LH_PL == 7560024
replace type_PID = 1 if countryelection_FE == 25 & PID_who == 7560024

replace party_voted = 336 if countryelection_FE == 25 & IMD3002_LH_PL == 7560016 //* Swiss Progressives
replace party_PID = 336 if countryelection_FE == 25 & PID_who == 7560016
replace type_voted = 6 if countryelection_FE == 25 & IMD3002_LH_PL == 7560016
replace type_PID = 6 if countryelection_FE == 25 & PID_who == 7560016

replace party_voted = 220 if countryelection_FE == 25 & IMD3002_LH_PL == 7560025 //* Conservative Democratic Party
replace party_PID = 220 if countryelection_FE == 25 & PID_who == 7560025
replace type_voted = 1 if countryelection_FE == 25 & IMD3002_LH_PL == 7560025
replace type_PID = 1 if countryelection_FE == 25 & PID_who == 7560025

replace party_voted = 216 if countryelection_FE == 25 & IMD3002_LH_PL == 7560019 //* Center Parties
replace party_PID = 216 if countryelection_FE == 25 & PID_who == 7560019
replace type_voted = 3 if countryelection_FE == 25 & IMD3002_LH_PL == 7560019
replace type_PID = 3 if countryelection_FE == 25 & PID_who == 7560019

replace party_voted = 337 if countryelection_FE == 25 & IMD3002_LH_PL == 7560017 //* Autonomous Socialists
replace party_PID = 337 if countryelection_FE == 25 & PID_who == 7560017
replace type_voted = 6 if countryelection_FE == 25 & IMD3002_LH_PL == 7560017
replace type_PID = 6 if countryelection_FE == 25 & PID_who == 7560017

//* Switzerland 2003

replace incumbent_voted = 1 if countryelection_FE == 26 & inlist(IMD3002_LH_PL,7560001,7560002,7560003,7560024,7560020)
replace incumbent_PID = 1 if countryelection_FE == 26 & inlist(PID_who,7560001,7560002,7560003,7560024,7560020)


replace party_voted = 202 if countryelection_FE == 26 & IMD3002_LH_PL == 7560001 //* Swiss People's Party
replace party_PID = 202 if countryelection_FE == 26 & PID_who == 7560001
replace type_voted = 5 if countryelection_FE == 26 & IMD3002_LH_PL == 7560001
replace type_PID = 5 if countryelection_FE == 26 & PID_who == 7560001

replace party_voted = 203 if countryelection_FE == 26 & IMD3002_LH_PL == 7560002 //* Swiss SDP
replace party_PID = 203 if countryelection_FE == 26 & PID_who == 7560002
replace type_voted = 1 if countryelection_FE == 26 & IMD3002_LH_PL == 7560002
replace type_PID = 1 if countryelection_FE == 26 & PID_who == 7560002

replace party_voted = 204 if countryelection_FE == 26 & IMD3002_LH_PL == 7560003 | countryelection_FE == 26 & IMD3002_LH_PL == 7560020   //* Swiss ChristDem
replace party_PID = 204 if countryelection_FE == 26 & PID_who == 7560003 | countryelection_FE == 26 & PID_who == 7560020
replace type_voted = 1 if countryelection_FE == 26 & IMD3002_LH_PL == 7560003 | countryelection_FE == 26 & IMD3002_LH_PL == 7560020
replace type_PID = 1 if countryelection_FE == 26 & PID_who == 7560003 | countryelection_FE == 26 & PID_who == 7560020

replace party_voted = 206 if countryelection_FE == 26 & IMD3002_LH_PL == 7560005 //* Swiss Greens
replace party_PID = 206 if countryelection_FE == 26 & PID_who == 7560005
replace type_voted = 2 if countryelection_FE == 26 & IMD3002_LH_PL == 7560005
replace type_PID = 2 if countryelection_FE == 26 & PID_who == 7560005

replace party_voted = 207 if countryelection_FE == 26 & IMD3002_LH_PL == 7560006 //* Evangelical People's
replace party_PID = 207 if countryelection_FE == 26 & PID_who == 7560006
replace type_voted = 1 if countryelection_FE == 26 & IMD3002_LH_PL == 7560006
replace type_PID = 1 if countryelection_FE == 26 & PID_who == 7560006

replace party_voted = 208 if countryelection_FE == 26 & IMD3002_LH_PL == 7560007 //* Party of Labour
replace party_PID = 208 if countryelection_FE == 26 & PID_who == 7560007
replace type_voted = 6 if countryelection_FE == 26 & IMD3002_LH_PL == 7560007
replace type_PID = 6 if countryelection_FE == 26 & PID_who == 7560007

replace party_voted = 209 if countryelection_FE == 26 & IMD3002_LH_PL == 7560008 //* Ticino League
replace party_PID = 209 if countryelection_FE == 26 & PID_who == 7560008
replace type_voted = 7 if countryelection_FE == 26 & IMD3002_LH_PL == 7560008
replace type_PID = 7 if countryelection_FE == 26 & PID_who == 7560008

replace party_voted = 210 if countryelection_FE == 26 & IMD3002_LH_PL == 7560009 //* Swiss FDU
replace party_PID = 210 if countryelection_FE == 26 & PID_who == 7560009
replace type_voted = 7 if countryelection_FE == 26 & IMD3002_LH_PL == 7560009
replace type_PID = 7 if countryelection_FE == 26 & PID_who == 7560009

replace party_voted = 211 if countryelection_FE == 26 & IMD3002_LH_PL == 7560010 //* Swiss Democrats
replace party_PID = 211 if countryelection_FE == 26 & PID_who == 7560010
replace type_voted = 7 if countryelection_FE == 26 & IMD3002_LH_PL == 7560010
replace type_PID = 7 if countryelection_FE == 26 & PID_who == 7560010

replace party_voted = 212 if countryelection_FE == 26 & IMD3002_LH_PL == 7560012 //* Solidarities
replace party_PID = 212 if countryelection_FE == 26 & PID_who == 7560012
replace type_voted = 6 if countryelection_FE == 26 & IMD3002_LH_PL == 7560012
replace type_PID = 6 if countryelection_FE == 26 & PID_who == 7560012

replace party_voted = 213 if countryelection_FE == 26 & IMD3002_LH_PL == 7560013 //* Swiss Freedom Party
replace party_PID = 213 if countryelection_FE == 26 & PID_who == 7560013
replace type_voted = 7 if countryelection_FE == 26 & IMD3002_LH_PL == 7560013
replace type_PID = 7 if countryelection_FE == 26 & PID_who == 7560013

replace party_voted = 214 if countryelection_FE == 26 & IMD3002_LH_PL == 7560014 //* Liberal Party
replace party_PID = 214 if countryelection_FE == 26 & PID_who == 7560014
replace type_voted = 1 if countryelection_FE == 26 & IMD3002_LH_PL == 7560014
replace type_PID = 1 if countryelection_FE == 26 & PID_who == 7560014

replace party_voted = 217 if countryelection_FE == 26 & IMD3002_LH_PL == 7560022 //* Indep Alliance
replace party_PID = 217 if countryelection_FE == 26 & PID_who == 7560022
replace type_voted = 2 if countryelection_FE == 26 & IMD3002_LH_PL == 7560022
replace type_PID = 2 if countryelection_FE == 26 & PID_who == 7560022

replace party_voted = 215 if countryelection_FE == 26 & IMD3002_LH_PL == 7560015 //* Feminist and Greens
replace party_PID = 215 if countryelection_FE == 26 & PID_who == 7560015
replace type_voted = 6 if countryelection_FE == 26 & IMD3002_LH_PL == 7560015
replace type_PID = 6 if countryelection_FE == 26 & PID_who == 7560015

replace party_voted = 205 if countryelection_FE == 26 & IMD3002_LH_PL == 7560024 //* Radical Democratic Party
replace party_PID = 205 if countryelection_FE == 26 & PID_who == 7560024
replace type_voted = 1 if countryelection_FE == 26 & IMD3002_LH_PL == 7560024
replace type_PID = 1 if countryelection_FE == 26 & PID_who == 7560024

replace party_voted = 336 if countryelection_FE == 26 & IMD3002_LH_PL == 7560016 //* Swiss Progressives
replace party_PID = 336 if countryelection_FE == 26 & PID_who == 7560016
replace type_voted = 7 if countryelection_FE == 26 & IMD3002_LH_PL == 7560016
replace type_PID = 7 if countryelection_FE == 26 & PID_who == 7560016

replace party_voted = 220 if countryelection_FE == 26 & IMD3002_LH_PL == 7560025 //* Conservative Democratic Party
replace party_PID = 220 if countryelection_FE == 26 & PID_who == 7560025
replace type_voted = 1 if countryelection_FE == 26 & IMD3002_LH_PL == 7560025
replace type_PID = 1 if countryelection_FE == 26 & PID_who == 7560025

replace party_voted = 216 if countryelection_FE == 26 & IMD3002_LH_PL == 7560019 //* Center Parties
replace party_PID = 216 if countryelection_FE == 26 & PID_who == 7560019
replace type_voted = 3 if countryelection_FE == 26 & IMD3002_LH_PL == 7560019
replace type_PID = 3 if countryelection_FE == 26 & PID_who == 7560019

replace party_voted = 337 if countryelection_FE == 26 & IMD3002_LH_PL == 7560017 //* Autonomous Socialists
replace party_PID = 337 if countryelection_FE == 26 & PID_who == 7560017
replace type_voted = 6 if countryelection_FE == 26 & IMD3002_LH_PL == 7560017
replace type_PID = 6 if countryelection_FE == 26 & PID_who == 7560017

replace party_voted = 221 if countryelection_FE == 26 & IMD3002_LH_PL == 7560026 //* Christian Social Party
replace party_PID = 221 if countryelection_FE == 26 & PID_who == 7560026
replace type_voted = 3 if countryelection_FE == 26 & IMD3002_LH_PL == 7560026
replace type_PID = 3 if countryelection_FE == 26 & PID_who == 7560026

//* Switzerland 2007

replace incumbent_voted = 1 if countryelection_FE == 27 & inlist(IMD3002_LH_PL,7560001,7560002,7560003,7560024,7560020)
replace incumbent_PID = 1 if countryelection_FE == 27 & inlist(PID_who,7560001,7560002,7560003,7560024,7560020)

replace party_voted = 202 if countryelection_FE == 27 & IMD3002_LH_PL == 7560001 //* Swiss People's Party
replace party_PID = 202 if countryelection_FE == 27 & PID_who == 7560001
replace type_voted = 5 if countryelection_FE == 27 & IMD3002_LH_PL == 7560001
replace type_PID = 5 if countryelection_FE == 27 & PID_who == 7560001

replace party_voted = 203 if countryelection_FE == 27 & IMD3002_LH_PL == 7560002 //* Swiss SDP
replace party_PID = 203 if countryelection_FE == 27 & PID_who == 7560002
replace type_voted = 1 if countryelection_FE == 27 & IMD3002_LH_PL == 7560002
replace type_PID = 1 if countryelection_FE == 27 & PID_who == 7560002

replace party_voted = 204 if countryelection_FE == 27 & IMD3002_LH_PL == 7560003 | countryelection_FE == 27 & IMD3002_LH_PL == 7560020   //* Swiss ChristDem
replace party_PID = 204 if countryelection_FE == 27 & PID_who == 7560003 | countryelection_FE == 27 & PID_who == 7560020
replace type_voted = 1 if countryelection_FE == 27 & IMD3002_LH_PL == 7560003 | countryelection_FE == 27 & IMD3002_LH_PL == 7560020
replace type_PID = 1 if countryelection_FE == 27 & PID_who == 7560003 | countryelection_FE == 27 & PID_who == 7560020

replace party_voted = 206 if countryelection_FE == 27 & IMD3002_LH_PL == 7560005 //* Swiss Greens
replace party_PID = 206 if countryelection_FE == 27 & PID_who == 7560005
replace type_voted = 2 if countryelection_FE == 27 & IMD3002_LH_PL == 7560005
replace type_PID = 2 if countryelection_FE == 27 & PID_who == 7560005

replace party_voted = 207 if countryelection_FE == 27 & IMD3002_LH_PL == 7560006 //* Evangelical People's
replace party_PID = 207 if countryelection_FE == 27 & PID_who == 7560006
replace type_voted = 1 if countryelection_FE == 27 & IMD3002_LH_PL == 7560006
replace type_PID = 1 if countryelection_FE == 27 & PID_who == 7560006

replace party_voted = 208 if countryelection_FE == 27 & IMD3002_LH_PL == 7560007 //* Party of Labour
replace party_PID = 208 if countryelection_FE == 27 & PID_who == 7560007
replace type_voted = 6 if countryelection_FE == 27 & IMD3002_LH_PL == 7560007
replace type_PID = 6 if countryelection_FE == 27 & PID_who == 7560007

replace party_voted = 209 if countryelection_FE == 27 & IMD3002_LH_PL == 7560008 //* Ticino League
replace party_PID = 209 if countryelection_FE == 27 & PID_who == 7560008
replace type_voted = 7 if countryelection_FE == 27 & IMD3002_LH_PL == 7560008
replace type_PID = 7 if countryelection_FE == 27 & PID_who == 7560008

replace party_voted = 210 if countryelection_FE == 27 & IMD3002_LH_PL == 7560009 //* Swiss FDU
replace party_PID = 210 if countryelection_FE == 27 & PID_who == 7560009
replace type_voted = 7 if countryelection_FE == 27 & IMD3002_LH_PL == 7560009
replace type_PID = 7 if countryelection_FE == 27 & PID_who == 7560009

replace party_voted = 211 if countryelection_FE == 27 & IMD3002_LH_PL == 7560010 //* Swiss Democrats
replace party_PID = 211 if countryelection_FE == 27 & PID_who == 7560010
replace type_voted = 7 if countryelection_FE == 27 & IMD3002_LH_PL == 7560010
replace type_PID = 7 if countryelection_FE == 27 & PID_who == 7560010

replace party_voted = 212 if countryelection_FE == 27 & IMD3002_LH_PL == 7560012 //* Solidarities
replace party_PID = 212 if countryelection_FE == 27 & PID_who == 7560012
replace type_voted = 6 if countryelection_FE == 27 & IMD3002_LH_PL == 7560012
replace type_PID = 6 if countryelection_FE == 27 & PID_who == 7560012

replace party_voted = 213 if countryelection_FE == 27 & IMD3002_LH_PL == 7560013 //* Swiss Freedom Party
replace party_PID = 213 if countryelection_FE == 27 & PID_who == 7560013
replace type_voted = 7 if countryelection_FE == 27 & IMD3002_LH_PL == 7560013
replace type_PID = 7 if countryelection_FE == 27 & PID_who == 7560013

replace party_voted = 214 if countryelection_FE == 27 & IMD3002_LH_PL == 7560014 //* Liberal Party
replace party_PID = 214 if countryelection_FE == 27 & PID_who == 7560014
replace type_voted = 1 if countryelection_FE == 27 & IMD3002_LH_PL == 7560014
replace type_PID = 1 if countryelection_FE == 27 & PID_who == 7560014

replace party_voted = 217 if countryelection_FE == 27 & IMD3002_LH_PL == 7560022 //* Indep Alliance
replace party_PID = 217 if countryelection_FE == 27 & PID_who == 7560022
replace type_voted = 2 if countryelection_FE == 27 & IMD3002_LH_PL == 7560022
replace type_PID = 2 if countryelection_FE == 27 & PID_who == 7560022

replace party_voted = 215 if countryelection_FE == 27 & IMD3002_LH_PL == 7560015 //* Feminist and Greens
replace party_PID = 215 if countryelection_FE == 27 & PID_who == 7560015
replace type_voted = 6 if countryelection_FE == 27 & IMD3002_LH_PL == 7560015
replace type_PID = 6 if countryelection_FE == 27 & PID_who == 7560015

replace party_voted = 205 if countryelection_FE == 27 & IMD3002_LH_PL == 7560024 //* Radical Democratic Party
replace party_PID = 205 if countryelection_FE == 27 & PID_who == 7560024
replace type_voted = 1 if countryelection_FE == 27 & IMD3002_LH_PL == 7560024
replace type_PID = 1 if countryelection_FE == 27 & PID_who == 7560024

replace party_voted = 221 if countryelection_FE == 27 & IMD3002_LH_PL == 7560026 //* Christian Social Party
replace party_PID = 221 if countryelection_FE == 27 & PID_who == 7560026
replace type_voted = 3 if countryelection_FE == 27 & IMD3002_LH_PL == 7560026
replace type_PID = 3 if countryelection_FE == 27 & PID_who == 7560026

replace party_voted = 336 if countryelection_FE == 27 & IMD3002_LH_PL == 7560016 //* Swiss Progressives
replace party_PID = 336 if countryelection_FE == 27 & PID_who == 7560016
replace type_voted = 7 if countryelection_FE == 27 & IMD3002_LH_PL == 7560016
replace type_PID = 7 if countryelection_FE == 27 & PID_who == 7560016

replace party_voted = 220 if countryelection_FE == 27 & IMD3002_LH_PL == 7560025 //* Conservative Democratic Party
replace party_PID = 220 if countryelection_FE == 27 & PID_who == 7560025
replace type_voted = 1 if countryelection_FE == 27 & IMD3002_LH_PL == 7560025
replace type_PID = 1 if countryelection_FE == 27 & PID_who == 7560025

replace party_voted = 216 if countryelection_FE == 27 & IMD3002_LH_PL == 7560019 //* Center Parties
replace party_PID = 216 if countryelection_FE == 27 & PID_who == 7560019
replace type_voted = 3 if countryelection_FE == 27 & IMD3002_LH_PL == 7560019
replace type_PID = 3 if countryelection_FE == 27 & PID_who == 7560019

replace party_voted = 337 if countryelection_FE == 27 & IMD3002_LH_PL == 7560017 //* Autonomous Socialists
replace party_PID = 337 if countryelection_FE == 27 & PID_who == 7560017
replace type_voted = 6 if countryelection_FE == 27 & IMD3002_LH_PL == 7560017
replace type_PID = 6 if countryelection_FE == 27 & PID_who == 7560017

//* Switzerland 2011

replace incumbent_voted = 1 if countryelection_FE == 28 & inlist(IMD3002_LH_PL,7560001,7560002,7560003,7560024,7560020,7560026)
replace incumbent_PID = 1 if countryelection_FE == 28 & inlist(PID_who,7560001,7560002,7560003,7560024,7560020,7560026)

replace party_voted = 202 if countryelection_FE == 28 & IMD3002_LH_PL == 7560001 //* Swiss People's Party
replace party_PID = 202 if countryelection_FE == 28 & PID_who == 7560001
replace type_voted = 5 if countryelection_FE == 28 & IMD3002_LH_PL == 7560001
replace type_PID = 5 if countryelection_FE == 28 & PID_who == 7560001

replace party_voted = 203 if countryelection_FE == 28 & IMD3002_LH_PL == 7560002 //* Swiss SDP
replace party_PID = 203 if countryelection_FE == 28 & PID_who == 7560002
replace type_voted = 1 if countryelection_FE == 28 & IMD3002_LH_PL == 7560002
replace type_PID = 1 if countryelection_FE == 28 & PID_who == 7560002

replace party_voted = 204 if countryelection_FE == 28 & IMD3002_LH_PL == 7560003 | countryelection_FE == 28 & IMD3002_LH_PL == 7560020   //* Swiss ChristDem
replace party_PID = 204 if countryelection_FE == 28 & PID_who == 7560003 | countryelection_FE == 28 & PID_who == 7560020
replace type_voted = 1 if countryelection_FE == 28 & IMD3002_LH_PL == 7560003 | countryelection_FE == 28 & IMD3002_LH_PL == 7560020
replace type_PID = 1 if countryelection_FE == 28 & PID_who == 7560003 | countryelection_FE == 28 & PID_who == 7560020

replace party_voted = 206 if countryelection_FE == 28 & IMD3002_LH_PL == 7560005 //* Swiss Greens
replace party_PID = 206 if countryelection_FE == 28 & PID_who == 7560005
replace type_voted = 2 if countryelection_FE == 28 & IMD3002_LH_PL == 7560005
replace type_PID = 2 if countryelection_FE == 28 & PID_who == 7560005

replace party_voted = 207 if countryelection_FE == 28 & IMD3002_LH_PL == 7560006 //* Evangelical People's
replace party_PID = 207 if countryelection_FE == 28 & PID_who == 7560006
replace type_voted = 1 if countryelection_FE == 28 & IMD3002_LH_PL == 7560006
replace type_PID = 1 if countryelection_FE == 28 & PID_who == 7560006

replace party_voted = 208 if countryelection_FE == 28 & IMD3002_LH_PL == 7560007 //* Party of Labour
replace party_PID = 208 if countryelection_FE == 28 & PID_who == 7560007
replace type_voted = 6 if countryelection_FE == 28 & IMD3002_LH_PL == 7560007
replace type_PID = 6 if countryelection_FE == 28 & PID_who == 7560007

replace party_voted = 209 if countryelection_FE == 28 & IMD3002_LH_PL == 7560008 //* Ticino League
replace party_PID = 209 if countryelection_FE == 28 & PID_who == 7560008
replace type_voted = 7 if countryelection_FE == 28 & IMD3002_LH_PL == 7560008
replace type_PID = 7 if countryelection_FE == 28 & PID_who == 7560008

replace party_voted = 210 if countryelection_FE == 28 & IMD3002_LH_PL == 7560009 //* Swiss FDU
replace party_PID = 210 if countryelection_FE == 28 & PID_who == 7560009
replace type_voted = 7 if countryelection_FE == 28 & IMD3002_LH_PL == 7560009
replace type_PID = 7 if countryelection_FE == 28 & PID_who == 7560009

replace party_voted = 211 if countryelection_FE == 28 & IMD3002_LH_PL == 7560010 //* Swiss Democrats
replace party_PID = 211 if countryelection_FE == 28 & PID_who == 7560010
replace type_voted = 7 if countryelection_FE == 28 & IMD3002_LH_PL == 7560010
replace type_PID = 7 if countryelection_FE == 28 & PID_who == 7560010

replace party_voted = 212 if countryelection_FE == 28 & IMD3002_LH_PL == 7560012 //* Solidarities
replace party_PID = 212 if countryelection_FE == 28 & PID_who == 7560012
replace type_voted = 6 if countryelection_FE == 28 & IMD3002_LH_PL == 7560012
replace type_PID = 6 if countryelection_FE == 28 & PID_who == 7560012

replace party_voted = 213 if countryelection_FE == 28 & IMD3002_LH_PL == 7560013 //* Swiss Freedom Party
replace party_PID = 213 if countryelection_FE == 28 & PID_who == 7560013
replace type_voted = 7 if countryelection_FE == 28 & IMD3002_LH_PL == 7560013
replace type_PID = 7 if countryelection_FE == 28 & PID_who == 7560013

replace party_voted = 214 if countryelection_FE == 28 & IMD3002_LH_PL == 7560014 //* Liberal Party
replace party_PID = 214 if countryelection_FE == 28 & PID_who == 7560014
replace type_voted = 1 if countryelection_FE == 28 & IMD3002_LH_PL == 7560014
replace type_PID = 1 if countryelection_FE == 28 & PID_who == 7560014

replace party_voted = 217 if countryelection_FE == 28 & IMD3002_LH_PL == 7560022 //* Indep Alliance
replace party_PID = 217 if countryelection_FE == 28 & PID_who == 7560022
replace type_voted = 2 if countryelection_FE == 28 & IMD3002_LH_PL == 7560022
replace type_PID = 2 if countryelection_FE == 28 & PID_who == 7560022

replace party_voted = 215 if countryelection_FE == 28 & IMD3002_LH_PL == 7560015 //* Feminist and Greens
replace party_PID = 215 if countryelection_FE == 28 & PID_who == 7560015
replace type_voted = 6 if countryelection_FE == 28 & IMD3002_LH_PL == 7560015
replace type_PID = 6 if countryelection_FE == 28 & PID_who == 7560015

replace party_voted = 205 if countryelection_FE == 28 & IMD3002_LH_PL == 7560024 | countryelection_FE == 28 & IMD3002_LH_PL == 7560004 //* Radical Democratic Party
replace party_PID = 205 if countryelection_FE == 28 & PID_who == 7560024 | countryelection_FE == 28 & PID_who == 7560004
replace type_voted = 1 if countryelection_FE == 28 & IMD3002_LH_PL == 7560024 | countryelection_FE == 28 & IMD3002_LH_PL == 7560004
replace type_PID = 1 if countryelection_FE == 28 & PID_who == 7560024 | countryelection_FE == 28 & PID_who == 7560004

replace party_voted = 221 if countryelection_FE == 28 & IMD3002_LH_PL == 7560026 //* Christian Social Party
replace party_PID = 221 if countryelection_FE == 28 & PID_who == 7560026
replace type_voted = 3 if countryelection_FE == 28 & IMD3002_LH_PL == 7560026
replace type_PID = 3 if countryelection_FE == 28 & PID_who == 7560026

replace party_voted = 336 if countryelection_FE == 28 & IMD3002_LH_PL == 7560016 //* Swiss Progressives
replace party_PID = 336 if countryelection_FE == 28 & PID_who == 7560016
replace type_voted = 6 if countryelection_FE == 28 & IMD3002_LH_PL == 7560016
replace type_PID = 6 if countryelection_FE == 28 & PID_who == 7560016

replace party_voted = 343 if countryelection_FE == 28 & IMD3002_LH_PL == 7560021 //* Green Liberals
replace party_PID = 343 if countryelection_FE == 28 & PID_who == 7560021
replace type_voted = 3 if countryelection_FE == 28 & IMD3002_LH_PL == 7560021
replace type_PID = 3 if countryelection_FE == 28 & PID_who == 7560021

replace party_voted = 218 if countryelection_FE == 28 & IMD3002_LH_PL == 7560023 //* Geneva Citizens
replace party_PID = 218 if countryelection_FE == 28 & PID_who == 7560023
replace type_voted = 7 if countryelection_FE == 28 & IMD3002_LH_PL == 7560023
replace type_PID = 7 if countryelection_FE == 28 & PID_who == 7560023

replace party_voted = 220 if countryelection_FE == 28 & IMD3002_LH_PL == 7560025 //* Conservative Democratic Party
replace party_PID = 220 if countryelection_FE == 28 & PID_who == 7560025
replace type_voted = 1 if countryelection_FE == 28 & IMD3002_LH_PL == 7560025
replace type_PID = 1 if countryelection_FE == 28 & PID_who == 7560025

replace party_voted = 216 if countryelection_FE == 28 & IMD3002_LH_PL == 7560019 //* Center Parties
replace party_PID = 216 if countryelection_FE == 28 & PID_who == 7560019
replace type_voted = 3 if countryelection_FE == 28 & IMD3002_LH_PL == 7560019
replace type_PID = 3 if countryelection_FE == 28 & PID_who == 7560019

replace party_voted = 337 if countryelection_FE == 28 & IMD3002_LH_PL == 7560017 //* Autonomous Socialists
replace party_PID = 337 if countryelection_FE == 28 & PID_who == 7560017
replace type_voted = 6 if countryelection_FE == 28 & IMD3002_LH_PL == 7560017
replace type_PID = 6 if countryelection_FE == 28 & PID_who == 7560017


//* Germany 2002

replace incumbent_voted = 1 if countryelection_FE == 37 & inlist(IMD3002_LH_PL,2760004,2760005) //* Greens/SPD
replace incumbent_PID = 1 if countryelection_FE == 37 & inlist(PID_who,2760004,2760005)

replace party_voted = 58 if countryelection_FE == 37 & IMD3002_LH_PL == 2760001 | countryelection_FE == 37 & IMD3002_LH_PL == 2760002 | countryelection_FE == 37 & IMD3002_LH_PL == 2760003  //* Christian Democratic Union /CSU
replace party_PID = 58 if countryelection_FE == 37 & PID_who == 2760001 | countryelection_FE == 37 & PID_who == 2760002 | countryelection_FE == 37 & PID_who == 2760003
replace type_voted = 1 if countryelection_FE == 37 & IMD3002_LH_PL == 2760001 | countryelection_FE == 37 & IMD3002_LH_PL == 2760002 | countryelection_FE == 37 & IMD3002_LH_PL == 2760003
replace type_PID = 1 if countryelection_FE == 37 & PID_who == 2760001 | countryelection_FE == 37 & PID_who == 2760002 | countryelection_FE == 37 & PID_who == 2760003

replace party_voted = 59 if countryelection_FE == 37 & IMD3002_LH_PL == 2760004 //* SPD
replace party_PID = 59 if countryelection_FE == 37 & PID_who == 2760004
replace type_voted = 1 if countryelection_FE == 37 & IMD3002_LH_PL == 2760004
replace type_PID = 1 if countryelection_FE == 37 & PID_who == 2760004

replace party_voted = 60 if countryelection_FE == 37 & IMD3002_LH_PL == 2760005 //* Greens
replace party_PID = 60 if countryelection_FE == 37 & PID_who == 2760005
replace type_voted = 1 if countryelection_FE == 37 & IMD3002_LH_PL == 2760005
replace type_PID = 1 if countryelection_FE == 37 & PID_who == 2760005

replace party_voted = 61 if countryelection_FE == 37 & IMD3002_LH_PL == 2760006 //* FDP
replace party_PID = 61 if countryelection_FE == 37 & PID_who == 2760006
replace type_voted = 1 if countryelection_FE == 37 & IMD3002_LH_PL == 2760006
replace type_PID = 1 if countryelection_FE == 37 & PID_who == 2760006

replace party_voted = 62 if countryelection_FE == 37 & IMD3002_LH_PL == 2760007 //* Die Linke
replace party_PID = 62 if countryelection_FE == 37 & PID_who == 2760007
replace type_voted = 6 if countryelection_FE == 37 & IMD3002_LH_PL == 2760007
replace type_PID = 6 if countryelection_FE == 37 & PID_who == 2760007

replace party_voted = 63 if countryelection_FE == 37 & IMD3002_LH_PL == 2760008 //* Republicans
replace party_PID = 63 if countryelection_FE == 37 & PID_who == 2760008
replace type_voted = 7 if countryelection_FE == 37 & IMD3002_LH_PL == 2760008
replace type_PID = 7 if countryelection_FE == 37 & PID_who == 2760008

replace party_voted = 64 if countryelection_FE == 37 & IMD3002_LH_PL == 2760009 //* NPD
replace party_PID = 64 if countryelection_FE == 37 & PID_who == 2760009
replace type_voted = 7 if countryelection_FE == 37 & IMD3002_LH_PL == 2760009
replace type_PID = 7 if countryelection_FE == 37 & PID_who == 2760009

replace party_voted = 69 if countryelection_FE == 37 & IMD3002_LH_PL == 2760019 //* Greys
replace party_PID = 69 if countryelection_FE == 37 & PID_who == 2760019
replace type_voted = 3 if countryelection_FE == 37 & IMD3002_LH_PL == 2760019
replace type_PID = 3 if countryelection_FE == 37 & PID_who == 2760019

replace party_voted = 70 if countryelection_FE == 37 & IMD3002_LH_PL == 2760020 //* Ecological Democratic Party
replace party_PID = 70 if countryelection_FE == 37 & PID_who == 2760020
replace type_voted = 3 if countryelection_FE == 37 & IMD3002_LH_PL == 2760020
replace type_PID = 3 if countryelection_FE == 37 & PID_who == 2760020

replace party_voted = 74 if countryelection_FE == 37 & IMD3002_LH_PL == 2760024 //* Schill Party
replace party_PID = 74 if countryelection_FE == 37 & PID_who == 2760024
replace type_voted = 7 if countryelection_FE == 37 & IMD3002_LH_PL == 2760024
replace type_PID = 7 if countryelection_FE == 37 & PID_who == 2760024

//* Germany 2002b

replace incumbent_voted = 1 if countryelection_FE == 38 & inlist(IMD3002_LH_PL,2760004,2760005) //* Greens/SPD
replace incumbent_PID = 1 if countryelection_FE == 38 & inlist(PID_who,2760004,2760005)

replace party_voted = 58 if countryelection_FE == 38 & IMD3002_LH_PL == 2760001 | countryelection_FE == 38 & IMD3002_LH_PL == 2760002 | countryelection_FE == 38 & IMD3002_LH_PL == 2760003  //* Christian Democratic Union /CSU
replace party_PID = 58 if countryelection_FE == 38 & PID_who == 2760001 | countryelection_FE == 38 & PID_who == 2760002 | countryelection_FE == 38 & PID_who == 2760003
replace type_voted = 1 if countryelection_FE == 38 & IMD3002_LH_PL == 2760001 | countryelection_FE == 38 & IMD3002_LH_PL == 2760002 | countryelection_FE == 38 & IMD3002_LH_PL == 2760003
replace type_PID = 1 if countryelection_FE == 38 & PID_who == 2760001 | countryelection_FE == 38 & PID_who == 2760002 | countryelection_FE == 38 & PID_who == 2760003

replace party_voted = 59 if countryelection_FE == 38 & IMD3002_LH_PL == 2760004 //* SPD
replace party_PID = 59 if countryelection_FE == 38 & PID_who == 2760004
replace type_voted = 1 if countryelection_FE == 38 & IMD3002_LH_PL == 2760004
replace type_PID = 1 if countryelection_FE == 38 & PID_who == 2760004

replace party_voted = 60 if countryelection_FE == 38 & IMD3002_LH_PL == 2760005 //* Greens
replace party_PID = 60 if countryelection_FE == 38 & PID_who == 2760005
replace type_voted = 1 if countryelection_FE == 38 & IMD3002_LH_PL == 2760005
replace type_PID = 1 if countryelection_FE == 38 & PID_who == 2760005

replace party_voted = 61 if countryelection_FE == 38 & IMD3002_LH_PL == 2760006 //* FDP
replace party_PID = 61 if countryelection_FE == 38 & PID_who == 2760006
replace type_voted = 1 if countryelection_FE == 38 & IMD3002_LH_PL == 2760006
replace type_PID = 1 if countryelection_FE == 38 & PID_who == 2760006

replace party_voted = 62 if countryelection_FE == 38 & IMD3002_LH_PL == 2760007 //* Die Linke
replace party_PID = 62 if countryelection_FE == 38 & PID_who == 2760007
replace type_voted = 6 if countryelection_FE == 38 & IMD3002_LH_PL == 2760007
replace type_PID = 6 if countryelection_FE == 38 & PID_who == 2760007

replace party_voted = 63 if countryelection_FE == 38 & IMD3002_LH_PL == 2760008 //* Republicans
replace party_PID = 63 if countryelection_FE == 38 & PID_who == 2760008
replace type_voted = 7 if countryelection_FE == 38 & IMD3002_LH_PL == 2760008
replace type_PID = 7 if countryelection_FE == 38 & PID_who == 2760008

replace party_voted = 64 if countryelection_FE == 38 & IMD3002_LH_PL == 2760009 //* NPD
replace party_PID = 64 if countryelection_FE == 38 & PID_who == 2760009
replace type_voted = 7 if countryelection_FE == 38 & IMD3002_LH_PL == 2760009
replace type_PID = 7 if countryelection_FE == 38 & PID_who == 2760009

replace party_voted = 69 if countryelection_FE == 38 & IMD3002_LH_PL == 2760019 //* Greys
replace party_PID = 69 if countryelection_FE == 38 & PID_who == 2760019
replace type_voted = 3 if countryelection_FE == 38 & IMD3002_LH_PL == 2760019
replace type_PID = 3 if countryelection_FE == 38 & PID_who == 2760019

replace party_voted = 70 if countryelection_FE == 38 & IMD3002_LH_PL == 2760020 //* Ecological Democratic Party
replace party_PID = 70 if countryelection_FE == 38 & PID_who == 2760020
replace type_voted = 3 if countryelection_FE == 38 & IMD3002_LH_PL == 2760020
replace type_PID = 3 if countryelection_FE == 38 & PID_who == 2760020

replace party_voted = 74 if countryelection_FE == 38 & IMD3002_LH_PL == 2760024 //* Schill Party
replace party_PID = 74 if countryelection_FE == 38 & PID_who == 2760024
replace type_voted = 7 if countryelection_FE == 38 & IMD3002_LH_PL == 2760024
replace type_PID = 7 if countryelection_FE == 38 & PID_who == 2760024

replace party_voted = 67 if countryelection_FE == 38 & IMD3002_LH_PL == 2760017 //* German People's Union
replace party_PID = 67 if countryelection_FE == 38 & PID_who == 2760017
replace type_voted = 7 if countryelection_FE == 38 & IMD3002_LH_PL == 2760017
replace type_PID = 7 if countryelection_FE == 38 & PID_who == 2760017

//* Germany 1998

replace incumbent_voted = 1 if countryelection_FE == 39 & inlist(IMD3002_LH_PL,2760001, 2760006) //* CDU/FDP/CSU
replace incumbent_PID = 1 if countryelection_FE == 39 & inlist(PID_who,2760001, 2760006)

replace party_voted = 58 if countryelection_FE == 39 & IMD3002_LH_PL == 2760001 | countryelection_FE == 39 & IMD3002_LH_PL == 2760002 | countryelection_FE == 39 & IMD3002_LH_PL == 2760003  //* Christian Democratic Union /CSU
replace party_PID = 58 if countryelection_FE == 39 & PID_who == 2760001 | countryelection_FE == 39 & PID_who == 2760002 | countryelection_FE == 39 & PID_who == 2760003
replace type_voted = 1 if countryelection_FE == 39 & IMD3002_LH_PL == 2760001 | countryelection_FE == 39 & IMD3002_LH_PL == 2760002 | countryelection_FE == 39 & IMD3002_LH_PL == 2760003
replace type_PID = 1 if countryelection_FE == 39 & PID_who == 2760001 | countryelection_FE == 39 & PID_who == 2760002 | countryelection_FE == 39 & PID_who == 2760003

replace party_voted = 59 if countryelection_FE == 39 & IMD3002_LH_PL == 2760004 //* SPD
replace party_PID = 59 if countryelection_FE == 39 & PID_who == 2760004
replace type_voted = 1 if countryelection_FE == 39 & IMD3002_LH_PL == 2760004
replace type_PID = 1 if countryelection_FE == 39 & PID_who == 2760004

replace party_voted = 60 if countryelection_FE == 39 & IMD3002_LH_PL == 2760005 //* Greens
replace party_PID = 60 if countryelection_FE == 39 & PID_who == 2760005
replace type_voted = 6 if countryelection_FE == 39 & IMD3002_LH_PL == 2760005
replace type_PID = 6 if countryelection_FE == 39 & PID_who == 2760005

replace party_voted = 61 if countryelection_FE == 39 & IMD3002_LH_PL == 2760006 //* FDP
replace party_PID = 61 if countryelection_FE == 39 & PID_who == 2760006
replace type_voted = 1 if countryelection_FE == 39 & IMD3002_LH_PL == 2760006
replace type_PID = 1 if countryelection_FE == 39 & PID_who == 2760006

replace party_voted = 62 if countryelection_FE == 39 & IMD3002_LH_PL == 2760007 //* Die Linke
replace party_PID = 62 if countryelection_FE == 39 & PID_who == 2760007
replace type_voted = 6 if countryelection_FE == 39 & IMD3002_LH_PL == 2760007
replace type_PID = 6 if countryelection_FE == 39 & PID_who == 2760007

replace party_voted = 63 if countryelection_FE == 39 & IMD3002_LH_PL == 2760008 //* Republicans
replace party_PID = 63 if countryelection_FE == 39 & PID_who == 2760008
replace type_voted = 7 if countryelection_FE == 39 & IMD3002_LH_PL == 2760008
replace type_PID = 7 if countryelection_FE == 39 & PID_who == 2760008

replace party_voted = 64 if countryelection_FE == 39 & IMD3002_LH_PL == 2760009 //* NPD
replace party_PID = 64 if countryelection_FE == 39 & PID_who == 2760009
replace type_voted = 7 if countryelection_FE == 39 & IMD3002_LH_PL == 2760009
replace type_PID = 7 if countryelection_FE == 39 & PID_who == 2760009

replace party_voted = 69 if countryelection_FE == 39 & IMD3002_LH_PL == 2760019 //* Greys
replace party_PID = 69 if countryelection_FE == 39 & PID_who == 2760019
replace type_voted = 3 if countryelection_FE == 39 & IMD3002_LH_PL == 2760019
replace type_PID = 3 if countryelection_FE == 39 & PID_who == 2760019

replace party_voted = 70 if countryelection_FE == 39 & IMD3002_LH_PL == 2760020 //* Ecological Democratic Party
replace party_PID = 70 if countryelection_FE == 39 & PID_who == 2760020
replace type_voted = 3 if countryelection_FE == 39 & IMD3002_LH_PL == 2760020
replace type_PID = 3 if countryelection_FE == 39 & PID_who == 2760020

replace party_voted = 74 if countryelection_FE == 39 & IMD3002_LH_PL == 2760024 //* Schill Party
replace party_PID = 74 if countryelection_FE == 39 & PID_who == 2760024
replace type_voted = 7 if countryelection_FE == 39 & IMD3002_LH_PL == 2760024
replace type_PID = 7 if countryelection_FE == 39 & PID_who == 2760024

replace party_voted = 67 if countryelection_FE == 39 & IMD3002_LH_PL == 2760017 //* German People's Union
replace party_PID = 67 if countryelection_FE == 39 & PID_who == 2760017
replace type_voted = 7 if countryelection_FE == 39 & IMD3002_LH_PL == 2760017
replace type_PID = 7 if countryelection_FE == 39 & PID_who == 2760017

//* Germany 2005

replace incumbent_voted = 1 if countryelection_FE == 40 & inlist(IMD3002_LH_PL,2760004,2760005) //* Greens/SPD
replace incumbent_PID = 1 if countryelection_FE == 40 & inlist(PID_who,2760004,2760005)

replace party_voted = 58 if countryelection_FE == 40 & IMD3002_LH_PL == 2760001 | countryelection_FE == 40 & IMD3002_LH_PL == 2760002 | countryelection_FE == 40 & IMD3002_LH_PL == 2760003  //* Christian Democratic Union /CSU
replace party_PID = 58 if countryelection_FE == 40 & PID_who == 2760001 | countryelection_FE == 40 & PID_who == 2760002 | countryelection_FE == 40 & PID_who == 2760003
replace type_voted = 1 if countryelection_FE == 40 & IMD3002_LH_PL == 2760001 | countryelection_FE == 40 & IMD3002_LH_PL == 2760002 | countryelection_FE == 40 & IMD3002_LH_PL == 2760003
replace type_PID = 1 if countryelection_FE == 40 & PID_who == 2760001 | countryelection_FE == 40 & PID_who == 2760002 | countryelection_FE == 40 & PID_who == 2760003

replace party_voted = 59 if countryelection_FE == 40 & IMD3002_LH_PL == 2760004 //* SPD
replace party_PID = 59 if countryelection_FE == 40 & PID_who == 2760004
replace type_voted = 1 if countryelection_FE == 40 & IMD3002_LH_PL == 2760004
replace type_PID = 1 if countryelection_FE == 40 & PID_who == 2760004

replace party_voted = 60 if countryelection_FE == 40 & IMD3002_LH_PL == 2760005 //* Greens
replace party_PID = 60 if countryelection_FE == 40 & PID_who == 2760005
replace type_voted = 1 if countryelection_FE == 40 & IMD3002_LH_PL == 2760005
replace type_PID = 1 if countryelection_FE == 40 & PID_who == 2760005

replace party_voted = 61 if countryelection_FE == 40 & IMD3002_LH_PL == 2760006 //* FDP
replace party_PID = 61 if countryelection_FE == 40 & PID_who == 2760006
replace type_voted = 1 if countryelection_FE == 40 & IMD3002_LH_PL == 2760006
replace type_PID = 1 if countryelection_FE == 40 & PID_who == 2760006

replace party_voted = 62 if countryelection_FE == 40 & IMD3002_LH_PL == 2760007 //* Die Linke
replace party_PID = 62 if countryelection_FE == 40 & PID_who == 2760007
replace type_voted = 6 if countryelection_FE == 40 & IMD3002_LH_PL == 2760007
replace type_PID = 6 if countryelection_FE == 40 & PID_who == 2760007

replace party_voted = 63 if countryelection_FE == 40 & IMD3002_LH_PL == 2760008 //* Republicans
replace party_PID = 63 if countryelection_FE == 40 & PID_who == 2760008
replace type_voted = 7 if countryelection_FE == 40 & IMD3002_LH_PL == 2760008
replace type_PID = 7 if countryelection_FE == 40 & PID_who == 2760008

replace party_voted = 64 if countryelection_FE == 40 & IMD3002_LH_PL == 2760009 //* NPD
replace party_PID = 64 if countryelection_FE == 40 & PID_who == 2760009
replace type_voted = 7 if countryelection_FE == 40 & IMD3002_LH_PL == 2760009
replace type_PID = 7 if countryelection_FE == 40 & PID_who == 2760009

replace party_voted = 69 if countryelection_FE == 40 & IMD3002_LH_PL == 2760019 //* Greys
replace party_PID = 69 if countryelection_FE == 40 & PID_who == 2760019
replace type_voted = 3 if countryelection_FE == 40 & IMD3002_LH_PL == 2760019
replace type_PID = 3 if countryelection_FE == 40 & PID_who == 2760019

replace party_voted = 70 if countryelection_FE == 40 & IMD3002_LH_PL == 2760020 //* Ecological Democratic Party
replace party_PID = 70 if countryelection_FE == 40 & PID_who == 2760020
replace type_voted = 3 if countryelection_FE == 40 & IMD3002_LH_PL == 2760020
replace type_PID = 3 if countryelection_FE == 40 & PID_who == 2760020

replace party_voted = 74 if countryelection_FE == 40 & IMD3002_LH_PL == 2760024 //* Schill Party
replace party_PID = 74 if countryelection_FE == 40 & PID_who == 2760024
replace type_voted = 7 if countryelection_FE == 40 & IMD3002_LH_PL == 2760024
replace type_PID = 7 if countryelection_FE == 40 & PID_who == 2760024

replace party_voted = 67 if countryelection_FE == 40 & IMD3002_LH_PL == 2760017 //* German People's Union
replace party_PID = 67 if countryelection_FE == 40 & PID_who == 2760017
replace type_voted = 7 if countryelection_FE == 40 & IMD3002_LH_PL == 2760017
replace type_PID = 7 if countryelection_FE == 40 & PID_who == 2760017

replace party_voted = 71 if countryelection_FE == 40 & IMD3002_LH_PL == 2760021 //* Bible Literalists
replace party_PID = 71 if countryelection_FE == 40 & PID_who == 2760021
replace type_voted = 3 if countryelection_FE == 40 & IMD3002_LH_PL == 2760021
replace type_PID = 3 if countryelection_FE == 40 & PID_who == 2760021

replace party_voted = 76 if countryelection_FE == 40 & IMD3002_LH_PL == 2760026 //* Animal Protection Party
replace party_PID = 76 if countryelection_FE == 40 & PID_who == 2760026
replace type_voted = 2 if countryelection_FE == 40 & IMD3002_LH_PL == 2760026
replace type_PID = 2 if countryelection_FE == 40 & PID_who == 2760026

replace party_voted = 80 if countryelection_FE == 40 & IMD3002_LH_PL == 2760031 //* Women's Party
replace party_PID = 80 if countryelection_FE == 40 & PID_who == 2760031
replace type_voted = 3 if countryelection_FE == 40 & IMD3002_LH_PL == 2760031
replace type_PID = 3 if countryelection_FE == 40 & PID_who == 2760031

replace party_voted = 81 if countryelection_FE == 40 & IMD3002_LH_PL == 2760032 //* Alliance, health and peace and social justice
replace party_PID = 81 if countryelection_FE == 40 & PID_who == 2760032
replace type_voted = 6 if countryelection_FE == 40 & IMD3002_LH_PL == 2760032
replace type_PID = 6 if countryelection_FE == 40 & PID_who == 2760032

replace party_voted = 82 if countryelection_FE == 40 & IMD3002_LH_PL == 2760034 //* Civic Movement
replace party_PID = 82 if countryelection_FE == 40 & PID_who == 2760034
replace type_voted = 7 if countryelection_FE == 40 & IMD3002_LH_PL == 2760034
replace type_PID = 7 if countryelection_FE == 40 & PID_who == 2760034

replace party_voted = 67 if countryelection_FE == 40 & IMD3002_LH_PL == 2760017 //* German People's Union
replace party_PID = 67 if countryelection_FE == 40 & PID_who == 2760017
replace type_voted = 7 if countryelection_FE == 40 & IMD3002_LH_PL == 2760017
replace type_PID = 7 if countryelection_FE == 40 & PID_who == 2760017

//* Germany 2009

replace incumbent_voted = 1 if countryelection_FE == 41 & inlist(IMD3002_LH_PL,2760001, 2760002, 2760003, 2760004) //* CDU-CSU/SPD
replace incumbent_PID = 1 if countryelection_FE == 41 & inlist(PID_who,2760001, 2760002, 2760003, 2760004)

replace party_voted = 58 if countryelection_FE == 41 & IMD3002_LH_PL == 2760001 | countryelection_FE == 41 & IMD3002_LH_PL == 2760002 | countryelection_FE == 41 & IMD3002_LH_PL == 2760003  //* Christian Democratic Union /CSU
replace party_PID = 58 if countryelection_FE == 41 & PID_who == 2760001 | countryelection_FE == 41 & PID_who == 2760002 | countryelection_FE == 41 & PID_who == 2760003
replace type_voted = 1 if countryelection_FE == 41 & IMD3002_LH_PL == 2760001 | countryelection_FE == 41 & IMD3002_LH_PL == 2760002 | countryelection_FE == 41 & IMD3002_LH_PL == 2760003
replace type_PID = 1 if countryelection_FE == 41 & PID_who == 2760001 | countryelection_FE == 41 & PID_who == 2760002 | countryelection_FE == 41 & PID_who == 2760003

replace party_voted = 59 if countryelection_FE == 41 & IMD3002_LH_PL == 2760004 //* SPD
replace party_PID = 59 if countryelection_FE == 41 & PID_who == 2760004
replace type_voted = 1 if countryelection_FE == 41 & IMD3002_LH_PL == 2760004
replace type_PID = 1 if countryelection_FE == 41 & PID_who == 2760004

replace party_voted = 60 if countryelection_FE == 41 & IMD3002_LH_PL == 2760005 //* Greens
replace party_PID = 60 if countryelection_FE == 41 & PID_who == 2760005
replace type_voted = 1 if countryelection_FE == 41 & IMD3002_LH_PL == 2760005
replace type_PID = 1 if countryelection_FE == 41 & PID_who == 2760005

replace party_voted = 61 if countryelection_FE == 41 & IMD3002_LH_PL == 2760006 //* FDP
replace party_PID = 61 if countryelection_FE == 41 & PID_who == 2760006
replace type_voted = 1 if countryelection_FE == 41 & IMD3002_LH_PL == 2760006
replace type_PID = 1 if countryelection_FE == 41 & PID_who == 2760006

replace party_voted = 62 if countryelection_FE == 41 & IMD3002_LH_PL == 2760007 //* Die Linke
replace party_PID = 62 if countryelection_FE == 41 & PID_who == 2760007
replace type_voted = 6 if countryelection_FE == 41 & IMD3002_LH_PL == 2760007
replace type_PID = 6 if countryelection_FE == 41 & PID_who == 2760007

replace party_voted = 63 if countryelection_FE == 41 & IMD3002_LH_PL == 2760008 //* Republicans
replace party_PID = 63 if countryelection_FE == 41 & PID_who == 2760008
replace type_voted = 7 if countryelection_FE == 41 & IMD3002_LH_PL == 2760008
replace type_PID = 7 if countryelection_FE == 41 & PID_who == 2760008

replace party_voted = 64 if countryelection_FE == 41 & IMD3002_LH_PL == 2760009 //* NPD
replace party_PID = 64 if countryelection_FE == 41 & PID_who == 2760009
replace type_voted = 7 if countryelection_FE == 41 & IMD3002_LH_PL == 2760009
replace type_PID = 7 if countryelection_FE == 41 & PID_who == 2760009

replace party_voted = 66 if countryelection_FE == 41 & IMD3002_LH_PL == 2760014 //* Pirates
replace party_PID = 66 if countryelection_FE == 41 & PID_who == 2760014
replace type_voted = 6 if countryelection_FE == 41 & IMD3002_LH_PL == 2760014
replace type_PID = 6 if countryelection_FE == 41 & PID_who == 2760014

replace party_voted = 68 if countryelection_FE == 41 & IMD3002_LH_PL == 2760018 //* South Schleswig Voters
replace party_PID = 68 if countryelection_FE == 41 & PID_who == 2760018
replace type_voted = 2 if countryelection_FE == 41 & IMD3002_LH_PL == 2760018
replace type_PID = 2 if countryelection_FE == 41 & PID_who == 2760018

replace party_voted = 69 if countryelection_FE == 41 & IMD3002_LH_PL == 2760019 //* Greys
replace party_PID = 69 if countryelection_FE == 41 & PID_who == 2760019
replace type_voted = 3 if countryelection_FE == 41 & IMD3002_LH_PL == 2760019
replace type_PID = 3 if countryelection_FE == 41 & PID_who == 2760019

replace party_voted = 70 if countryelection_FE == 41 & IMD3002_LH_PL == 2760020 //* Ecological Democratic Party
replace party_PID = 70 if countryelection_FE == 41 & PID_who == 2760020
replace type_voted = 3 if countryelection_FE == 41 & IMD3002_LH_PL == 2760020
replace type_PID = 3 if countryelection_FE == 41 & PID_who == 2760020

replace party_voted = 73 if countryelection_FE == 41 & IMD3002_LH_PL == 2760023 //* Generation Party
replace party_PID = 73 if countryelection_FE == 41 & PID_who == 2760023
replace type_voted = 3 if countryelection_FE == 41 & IMD3002_LH_PL == 2760023
replace type_PID = 3 if countryelection_FE == 41 & PID_who == 2760023

replace party_voted = 74 if countryelection_FE == 41 & IMD3002_LH_PL == 2760024 //* Schill Party
replace party_PID = 74 if countryelection_FE == 41 & PID_who == 2760024
replace type_voted = 7 if countryelection_FE == 41 & IMD3002_LH_PL == 2760024
replace type_PID = 7 if countryelection_FE == 41 & PID_who == 2760024

replace party_voted = 75 if countryelection_FE == 41 & IMD3002_LH_PL == 2760025 //* Free Voters
replace party_PID = 75 if countryelection_FE == 41 & PID_who == 2760025
replace type_voted = 3 if countryelection_FE == 41 & IMD3002_LH_PL == 2760025
replace type_PID = 3 if countryelection_FE == 41 & PID_who == 2760025

replace party_voted = 77 if countryelection_FE == 41 & IMD3002_LH_PL == 2760028 //* Family Party
replace party_PID = 77 if countryelection_FE == 41 & PID_who == 2760028
replace type_voted = 3 if countryelection_FE == 41 & IMD3002_LH_PL == 2760028
replace type_PID = 3 if countryelection_FE == 41 & PID_who == 2760028

replace party_voted = 78 if countryelection_FE == 41 & IMD3002_LH_PL == 2760029 //* Violet Spiritual Politics
replace party_PID = 78 if countryelection_FE == 41 & PID_who == 2760029
replace type_voted = 2 if countryelection_FE == 41 & IMD3002_LH_PL == 2760029
replace type_PID = 2 if countryelection_FE == 41 & PID_who == 2760029

replace party_voted = 67 if countryelection_FE == 41 & IMD3002_LH_PL == 2760017 //* German People's Union
replace party_PID = 67 if countryelection_FE == 41 & PID_who == 2760017
replace type_voted = 7 if countryelection_FE == 41 & IMD3002_LH_PL == 2760017
replace type_PID = 7 if countryelection_FE == 41 & PID_who == 2760017

replace party_voted = 71 if countryelection_FE == 41 & IMD3002_LH_PL == 2760021 //* Bible Literalists
replace party_PID = 71 if countryelection_FE == 41 & PID_who == 2760021
replace type_voted = 3 if countryelection_FE == 41 & IMD3002_LH_PL == 2760021
replace type_PID = 3 if countryelection_FE == 41 & PID_who == 2760021

replace party_voted = 76 if countryelection_FE == 41 & IMD3002_LH_PL == 2760026 //* Animal Protection Party
replace party_PID = 76 if countryelection_FE == 41 & PID_who == 2760026
replace type_voted = 2 if countryelection_FE == 41 & IMD3002_LH_PL == 2760026
replace type_PID = 2 if countryelection_FE == 41 & PID_who == 2760026

replace party_voted = 80 if countryelection_FE == 41 & IMD3002_LH_PL == 2760031 //* Women's Party
replace party_PID = 80 if countryelection_FE == 41 & PID_who == 2760031
replace type_voted = 2 if countryelection_FE == 41 & IMD3002_LH_PL == 2760031
replace type_PID = 2 if countryelection_FE == 41 & PID_who == 2760031

replace party_voted = 81 if countryelection_FE == 41 & IMD3002_LH_PL == 2760032 //* Alliance, health and peace and social justice
replace party_PID = 81 if countryelection_FE == 41 & PID_who == 2760032
replace type_voted = 6 if countryelection_FE == 41 & IMD3002_LH_PL == 2760032
replace type_PID = 6 if countryelection_FE == 41 & PID_who == 2760032

replace party_voted = 82 if countryelection_FE == 41 & IMD3002_LH_PL == 2760034 //* Civic Movement (LaRouche)
replace party_PID = 82 if countryelection_FE == 41 & PID_who == 2760034
replace type_voted = 7 if countryelection_FE == 41 & IMD3002_LH_PL == 2760034
replace type_PID = 7 if countryelection_FE == 41 & PID_who == 2760034

replace party_voted = 67 if countryelection_FE == 41 & IMD3002_LH_PL == 2760017 //* German People's Union
replace party_PID = 67 if countryelection_FE == 41 & PID_who == 2760017
replace type_voted = 7 if countryelection_FE == 41 & IMD3002_LH_PL == 2760017
replace type_PID = 7 if countryelection_FE == 41 & PID_who == 2760017



//* Germany 2013

replace incumbent_voted = 1 if countryelection_FE == 42 & inlist(IMD3002_LH_PL,2760001, 2760002, 2760003, 2760006) //* CDU/CSU/FDP
replace incumbent_PID = 1 if countryelection_FE == 42 & inlist(PID_who,2760001, 2760002, 2760003, 2760006)

replace party_voted = 58 if countryelection_FE == 42 & IMD3002_LH_PL == 2760001 | countryelection_FE == 42 & IMD3002_LH_PL == 2760002 | countryelection_FE == 42 & IMD3002_LH_PL == 2760003  //* Christian Democratic Union /CSU
replace party_PID = 58 if countryelection_FE == 42 & PID_who == 2760001 | countryelection_FE == 42 & PID_who == 2760002 | countryelection_FE == 42 & PID_who == 2760003
replace type_voted = 1 if countryelection_FE == 42 & IMD3002_LH_PL == 2760001 | countryelection_FE == 42 & IMD3002_LH_PL == 2760002 | countryelection_FE == 42 & IMD3002_LH_PL == 2760003
replace type_PID = 1 if countryelection_FE == 42 & PID_who == 2760001 | countryelection_FE == 42 & PID_who == 2760002 | countryelection_FE == 42 & PID_who == 2760003

replace party_voted = 59 if countryelection_FE == 42 & IMD3002_LH_PL == 2760004 //* SPD
replace party_PID = 59 if countryelection_FE == 42 & PID_who == 2760004
replace type_voted = 1 if countryelection_FE == 42 & IMD3002_LH_PL == 2760004
replace type_PID = 1 if countryelection_FE == 42 & PID_who == 2760004

replace party_voted = 60 if countryelection_FE == 42 & IMD3002_LH_PL == 2760005 //* Greens
replace party_PID = 60 if countryelection_FE == 42 & PID_who == 2760005
replace type_voted = 1 if countryelection_FE == 42 & IMD3002_LH_PL == 2760005
replace type_PID = 1 if countryelection_FE == 42 & PID_who == 2760005

replace party_voted = 61 if countryelection_FE == 42 & IMD3002_LH_PL == 2760006 //* FDP
replace party_PID = 61 if countryelection_FE == 42 & PID_who == 2760006
replace type_voted = 1 if countryelection_FE == 42 & IMD3002_LH_PL == 2760006
replace type_PID = 1 if countryelection_FE == 42 & PID_who == 2760006

replace party_voted = 62 if countryelection_FE == 42 & IMD3002_LH_PL == 2760007 //* Die Linke
replace party_PID = 62 if countryelection_FE == 42 & PID_who == 2760007
replace type_voted = 6 if countryelection_FE == 42 & IMD3002_LH_PL == 2760007
replace type_PID = 6 if countryelection_FE == 42 & PID_who == 2760007

replace party_voted = 63 if countryelection_FE == 42 & IMD3002_LH_PL == 2760008 //* Republicans
replace party_PID = 63 if countryelection_FE == 42 & PID_who == 2760008
replace type_voted = 7 if countryelection_FE == 42 & IMD3002_LH_PL == 2760008
replace type_PID = 7 if countryelection_FE == 42 & PID_who == 2760008

replace party_voted = 64 if countryelection_FE == 42 & IMD3002_LH_PL == 2760009 //* NPD
replace party_PID = 64 if countryelection_FE == 42 & PID_who == 2760009
replace type_voted = 7 if countryelection_FE == 42 & IMD3002_LH_PL == 2760009
replace type_PID = 7 if countryelection_FE == 42 & PID_who == 2760009

replace party_voted = 65 if countryelection_FE == 42 & IMD3002_LH_PL == 2760010 //* AfD
replace party_PID = 65 if countryelection_FE == 42 & PID_who == 2760010
replace type_voted = 7 if countryelection_FE == 42 & IMD3002_LH_PL == 2760010
replace type_PID = 7 if countryelection_FE == 42 & PID_who == 2760010

replace party_voted = 66 if countryelection_FE == 42 & IMD3002_LH_PL == 2760014 //* Pirates
replace party_PID = 66 if countryelection_FE == 42 & PID_who == 2760014
replace type_voted = 6 if countryelection_FE == 42 & IMD3002_LH_PL == 2760014
replace type_PID = 6 if countryelection_FE == 42 & PID_who == 2760014

replace party_voted = 68 if countryelection_FE == 42 & IMD3002_LH_PL == 2760018 //* South Schleswig Voters
replace party_PID = 68 if countryelection_FE == 42 & PID_who == 2760018
replace type_voted = 2 if countryelection_FE == 42 & IMD3002_LH_PL == 2760018
replace type_PID = 2 if countryelection_FE == 42 & PID_who == 2760018

replace party_voted = 69 if countryelection_FE == 42 & IMD3002_LH_PL == 2760019 //* Greys
replace party_PID = 69 if countryelection_FE == 42 & PID_who == 2760019
replace type_voted = 3 if countryelection_FE == 42 & IMD3002_LH_PL == 2760019
replace type_PID = 3 if countryelection_FE == 42 & PID_who == 2760019

replace party_voted = 70 if countryelection_FE == 42 & IMD3002_LH_PL == 2760020 //* Ecological Democratic Party
replace party_PID = 70 if countryelection_FE == 42 & PID_who == 2760020
replace type_voted = 3 if countryelection_FE == 42 & IMD3002_LH_PL == 2760020
replace type_PID = 3 if countryelection_FE == 42 & PID_who == 2760020

replace party_voted = 72 if countryelection_FE == 42 & IMD3002_LH_PL == 2760022 //* Pensioners
replace party_PID = 72 if countryelection_FE == 42 & PID_who == 2760022
replace type_voted = 3 if countryelection_FE == 42 & IMD3002_LH_PL == 2760022
replace type_PID = 3 if countryelection_FE == 42 & PID_who == 2760022

replace party_voted = 73 if countryelection_FE == 42 & IMD3002_LH_PL == 2760023 //* Generation Party
replace party_PID = 73 if countryelection_FE == 42 & PID_who == 2760023
replace type_voted = 3 if countryelection_FE == 42 & IMD3002_LH_PL == 2760023
replace type_PID = 3 if countryelection_FE == 42 & PID_who == 2760023

replace party_voted = 74 if countryelection_FE == 42 & IMD3002_LH_PL == 2760024 //* Schill Party
replace party_PID = 74 if countryelection_FE == 42 & PID_who == 2760024
replace type_voted = 7 if countryelection_FE == 42 & IMD3002_LH_PL == 2760024
replace type_PID = 7 if countryelection_FE == 42 & PID_who == 2760024

replace party_voted = 75 if countryelection_FE == 42 & IMD3002_LH_PL == 2760025 //* Free Voters
replace party_PID = 75 if countryelection_FE == 42 & PID_who == 2760025
replace type_voted = 3 if countryelection_FE == 42 & IMD3002_LH_PL == 2760025
replace type_PID = 3 if countryelection_FE == 42 & PID_who == 2760025

replace party_voted = 77 if countryelection_FE == 42 & IMD3002_LH_PL == 2760028 //* Family Party
replace party_PID = 77 if countryelection_FE == 42 & PID_who == 2760028
replace type_voted = 3 if countryelection_FE == 42 & IMD3002_LH_PL == 2760028
replace type_PID = 3 if countryelection_FE == 42 & PID_who == 2760028

replace party_voted = 78 if countryelection_FE == 42 & IMD3002_LH_PL == 2760029 //* Violet Spiritual Politics
replace party_PID = 78 if countryelection_FE == 42 & PID_who == 2760029
replace type_voted = 2 if countryelection_FE == 42 & IMD3002_LH_PL == 2760029
replace type_PID = 2 if countryelection_FE == 42 & PID_who == 2760029

replace party_voted = 67 if countryelection_FE == 42 & IMD3002_LH_PL == 2760017 //* German People's Union
replace party_PID = 67 if countryelection_FE == 42 & PID_who == 2760017
replace type_voted = 7 if countryelection_FE == 42 & IMD3002_LH_PL == 2760017
replace type_PID = 7 if countryelection_FE == 42 & PID_who == 2760017

replace party_voted = 71 if countryelection_FE == 42 & IMD3002_LH_PL == 2760021 //* Bible Literalists
replace party_PID = 71 if countryelection_FE == 42 & PID_who == 2760021
replace type_voted = 3 if countryelection_FE == 42 & IMD3002_LH_PL == 2760021
replace type_PID = 3 if countryelection_FE == 42 & PID_who == 2760021

replace party_voted = 76 if countryelection_FE == 42 & IMD3002_LH_PL == 2760026 //* Animal Protection Party
replace party_PID = 76 if countryelection_FE == 42 & PID_who == 2760026
replace type_voted = 2 if countryelection_FE == 42 & IMD3002_LH_PL == 2760026
replace type_PID = 2 if countryelection_FE == 42 & PID_who == 2760026

replace party_voted = 79 if countryelection_FE == 42 & IMD3002_LH_PL == 2760030 //* The Party
replace party_PID = 79 if countryelection_FE == 42 & PID_who == 2760030
replace type_voted = 2 if countryelection_FE == 42 & IMD3002_LH_PL == 2760030
replace type_PID = 2 if countryelection_FE == 42 & PID_who == 2760030

replace party_voted = 80 if countryelection_FE == 42 & IMD3002_LH_PL == 2760031 //* Women's Party
replace party_PID = 80 if countryelection_FE == 42 & PID_who == 2760031
replace type_voted = 2 if countryelection_FE == 42 & IMD3002_LH_PL == 2760031
replace type_PID = 2 if countryelection_FE == 42 & PID_who == 2760031

replace party_voted = 81 if countryelection_FE == 42 & IMD3002_LH_PL == 2760032 //* Alliance, health and peace and social justice
replace party_PID = 81 if countryelection_FE == 42 & PID_who == 2760032
replace type_voted = 6 if countryelection_FE == 42 & IMD3002_LH_PL == 2760032
replace type_PID = 6 if countryelection_FE == 42 & PID_who == 2760032

replace party_voted = 82 if countryelection_FE == 42 & IMD3002_LH_PL == 2760034 //*Civic Movement (LaRouche)
replace party_PID = 82 if countryelection_FE == 42 & PID_who == 2760034
replace type_voted = 7 if countryelection_FE == 42 & IMD3002_LH_PL == 2760034
replace type_PID = 7 if countryelection_FE == 42 & PID_who == 2760034

replace party_voted = 319 if countryelection_FE == 42 & IMD3002_LH_PL == 2760016 //* Bavarian Party
replace party_PID = 319 if countryelection_FE == 42 & PID_who == 2760016 
replace type_voted = 3 if countryelection_FE == 42 & IMD3002_LH_PL == 2760016 
replace type_PID = 3 if countryelection_FE == 42 & PID_who == 2760016 


//* Denmark 98


replace incumbent_voted = 1 if countryelection_FE == 43 & inlist(IMD3002_LH_PL,2080001,2080006) //* SDP/SocLibs
replace incumbent_PID = 1 if countryelection_FE == 43 & inlist(PID_who,2080001,2080006)

replace party_voted = 29 if countryelection_FE == 43 & IMD3002_LH_PL == 2080001 //*Danish SDP
replace party_PID = 29 if countryelection_FE == 43 & PID_who == 2080001
replace type_voted = 1 if countryelection_FE == 43 & IMD3002_LH_PL == 2080001
replace type_PID = 1 if countryelection_FE == 43 & PID_who == 2080001

replace party_voted = 30 if countryelection_FE == 43 & IMD3002_LH_PL == 2080002 //* Venstre (Libs)
replace party_PID = 30 if countryelection_FE == 43 & PID_who == 2080002
replace type_voted = 1 if countryelection_FE == 43 & IMD3002_LH_PL == 2080002
replace type_PID = 1 if countryelection_FE == 43 & PID_who == 2080002

replace party_voted = 31 if countryelection_FE == 43 & IMD3002_LH_PL == 2080003 //* Progress Party
replace party_PID = 31 if countryelection_FE == 43 & PID_who == 2080003
replace type_voted = 7 if countryelection_FE == 43 & IMD3002_LH_PL == 2080003
replace type_PID = 7 if countryelection_FE == 43 & PID_who == 2080003

replace party_voted = 32 if countryelection_FE == 43 & IMD3002_LH_PL == 2080004 //* Socialist People's Party
replace party_PID = 32 if countryelection_FE == 43 & PID_who == 2080004
replace type_voted = 1 if countryelection_FE == 43 & IMD3002_LH_PL == 2080004
replace type_PID = 1 if countryelection_FE == 43 & PID_who == 2080004

replace party_voted = 33 if countryelection_FE == 43 & IMD3002_LH_PL == 2080005 //* United Left
replace party_PID = 33 if countryelection_FE == 43 & PID_who == 2080005
replace type_voted = 6 if countryelection_FE == 43 & IMD3002_LH_PL == 2080005
replace type_PID = 6 if countryelection_FE == 43 & PID_who == 2080005

replace party_voted = 34 if countryelection_FE == 43 & IMD3002_LH_PL == 2080006 //* Social Libs
replace party_PID = 34 if countryelection_FE == 43 & PID_who == 2080006
replace type_voted = 1 if countryelection_FE == 43 & IMD3002_LH_PL == 2080006
replace type_PID = 1 if countryelection_FE == 43 & PID_who == 2080006

replace party_voted = 35 if countryelection_FE == 43 & IMD3002_LH_PL == 2080007 //* Conservative People's Party
replace party_PID = 35 if countryelection_FE == 43 & PID_who == 2080007
replace type_voted = 1 if countryelection_FE == 43 & IMD3002_LH_PL == 2080007
replace type_PID = 1 if countryelection_FE == 43 & PID_who == 2080007

replace party_voted = 36 if countryelection_FE == 43 & IMD3002_LH_PL == 2080008 //* Christian Democrats
replace party_PID = 36 if countryelection_FE == 43 & PID_who == 2080008
replace type_voted = 1 if countryelection_FE == 43 & IMD3002_LH_PL == 2080008
replace type_PID = 1 if countryelection_FE == 43 & PID_who == 2080008

replace party_voted = 38 if countryelection_FE == 43 & IMD3002_LH_PL == 2080010 //* Danish People's Party
replace party_PID = 38 if countryelection_FE == 43 & PID_who == 2080010
replace type_voted = 7 if countryelection_FE == 43 & IMD3002_LH_PL == 2080010
replace type_PID = 7 if countryelection_FE == 43 & PID_who == 2080010

replace party_voted = 39 if countryelection_FE == 43 & IMD3002_LH_PL == 2080011 //* Centre Democrats
replace party_PID = 39 if countryelection_FE == 43 & PID_who == 2080011
replace type_voted = 1 if countryelection_FE == 43 & IMD3002_LH_PL == 2080011
replace type_PID = 1 if countryelection_FE == 43 & PID_who == 2080011

replace party_voted = 40 if countryelection_FE == 43 & IMD3002_LH_PL == 2080014 //* Democratic Renewal
replace party_PID = 40 if countryelection_FE == 43 & PID_who == 2080014
replace type_voted = 6 if countryelection_FE == 43 & IMD3002_LH_PL == 2080014
replace type_PID = 6 if countryelection_FE == 43 & PID_who == 2080014

replace party_voted = 37 if countryelection_FE == 43 & IMD3002_LH_PL == 2080009 //* New Alliance
replace party_PID = 37 if countryelection_FE == 43 & PID_who == 2080009
replace type_voted = 3 if countryelection_FE == 43 & IMD3002_LH_PL == 2080009
replace type_PID = 3 if countryelection_FE == 43 & PID_who == 2080009


//* Denmark 2001

replace incumbent_voted = 1 if countryelection_FE == 44 & inlist(IMD3002_LH_PL,2080001,2080006) //* SDP/SocLibs
replace incumbent_PID = 1 if countryelection_FE == 44 & inlist(PID_who,2080001,2080006)

replace party_voted = 29 if countryelection_FE == 44 & IMD3002_LH_PL == 2080001 //*Danish SDP
replace party_PID = 29 if countryelection_FE == 44 & PID_who == 2080001
replace type_voted = 1 if countryelection_FE == 44 & IMD3002_LH_PL == 2080001
replace type_PID = 1 if countryelection_FE == 44 & PID_who == 2080001

replace party_voted = 30 if countryelection_FE == 44 & IMD3002_LH_PL == 2080002 //* Venstre (Libs)
replace party_PID = 30 if countryelection_FE == 44 & PID_who == 2080002
replace type_voted = 1 if countryelection_FE == 44 & IMD3002_LH_PL == 2080002
replace type_PID = 1 if countryelection_FE == 44 & PID_who == 2080002

replace party_voted = 31 if countryelection_FE == 44 & IMD3002_LH_PL == 2080003 //* Progress Party
replace party_PID = 31 if countryelection_FE == 44 & PID_who == 2080003
replace type_voted = 7 if countryelection_FE == 44 & IMD3002_LH_PL == 2080003
replace type_PID = 7 if countryelection_FE == 44 & PID_who == 2080003

replace party_voted = 32 if countryelection_FE == 44 & IMD3002_LH_PL == 2080004 //* Socialist People's Party
replace party_PID = 32 if countryelection_FE == 44 & PID_who == 2080004
replace type_voted = 1 if countryelection_FE == 44 & IMD3002_LH_PL == 2080004
replace type_PID = 1 if countryelection_FE == 44 & PID_who == 2080004

replace party_voted = 33 if countryelection_FE == 44 & IMD3002_LH_PL == 2080005 //* United Left
replace party_PID = 33 if countryelection_FE == 44 & PID_who == 2080005
replace type_voted = 6 if countryelection_FE == 44 & IMD3002_LH_PL == 2080005
replace type_PID = 6 if countryelection_FE == 44 & PID_who == 2080005

replace party_voted = 34 if countryelection_FE == 44 & IMD3002_LH_PL == 2080006 //* Social Libs
replace party_PID = 34 if countryelection_FE == 44 & PID_who == 2080006
replace type_voted = 1 if countryelection_FE == 44 & IMD3002_LH_PL == 2080006
replace type_PID = 1 if countryelection_FE == 44 & PID_who == 2080006

replace party_voted = 35 if countryelection_FE == 44 & IMD3002_LH_PL == 2080007 //* Conservative People's Party
replace party_PID = 35 if countryelection_FE == 44 & PID_who == 2080007
replace type_voted = 1 if countryelection_FE == 44 & IMD3002_LH_PL == 2080007
replace type_PID = 1 if countryelection_FE == 44 & PID_who == 2080007

replace party_voted = 36 if countryelection_FE == 44 & IMD3002_LH_PL == 2080008 //* Christian Democrats
replace party_PID = 36 if countryelection_FE == 44 & PID_who == 2080008
replace type_voted = 1 if countryelection_FE == 44 & IMD3002_LH_PL == 2080008
replace type_PID = 1 if countryelection_FE == 44 & PID_who == 2080008

replace party_voted = 38 if countryelection_FE == 44 & IMD3002_LH_PL == 2080010 //* Danish People's Party
replace party_PID = 38 if countryelection_FE == 44 & PID_who == 2080010
replace type_voted = 7 if countryelection_FE == 44 & IMD3002_LH_PL == 2080010
replace type_PID = 7 if countryelection_FE == 44 & PID_who == 2080010

replace party_voted = 39 if countryelection_FE == 44 & IMD3002_LH_PL == 2080011 //* Centre Democrats
replace party_PID = 39 if countryelection_FE == 44 & PID_who == 2080011
replace type_voted = 1 if countryelection_FE == 44 & IMD3002_LH_PL == 2080011
replace type_PID = 1 if countryelection_FE == 44 & PID_who == 2080011

replace party_voted = 40 if countryelection_FE == 44 & IMD3002_LH_PL == 2080014 //* Democratic Renewal
replace party_PID = 40 if countryelection_FE == 44 & PID_who == 2080014
replace type_voted = 6 if countryelection_FE == 44 & IMD3002_LH_PL == 2080014
replace type_PID = 6 if countryelection_FE == 44 & PID_who == 2080014

replace party_voted = 37 if countryelection_FE == 44 & IMD3002_LH_PL == 2080009 //* New Alliance
replace party_PID = 37 if countryelection_FE == 44 & PID_who == 2080009
replace type_voted = 3 if countryelection_FE == 44 & IMD3002_LH_PL == 2080009
replace type_PID = 3 if countryelection_FE == 44 & PID_who == 2080009

//* Denmark 2007

replace incumbent_voted = 1 if countryelection_FE == 45 & inlist(IMD3002_LH_PL,2080002,2080007) //* Venstre/ConsPP
replace incumbent_PID = 1 if countryelection_FE == 45 & inlist(PID_who,2080002,2080007)

replace party_voted = 29 if countryelection_FE == 45 & IMD3002_LH_PL == 2080001 //*Danish SDP
replace party_PID = 29 if countryelection_FE == 45 & PID_who == 2080001
replace type_voted = 1 if countryelection_FE == 45 & IMD3002_LH_PL == 2080001
replace type_PID = 1 if countryelection_FE == 45 & PID_who == 2080001

replace party_voted = 30 if countryelection_FE == 45 & IMD3002_LH_PL == 2080002 //* Venstre (Libs)
replace party_PID = 30 if countryelection_FE == 45 & PID_who == 2080002
replace type_voted = 1 if countryelection_FE == 45 & IMD3002_LH_PL == 2080002
replace type_PID = 1 if countryelection_FE == 45 & PID_who == 2080002

replace party_voted = 31 if countryelection_FE == 45 & IMD3002_LH_PL == 2080003 //* Progress Party
replace party_PID = 31 if countryelection_FE == 45 & PID_who == 2080003
replace type_voted = 7 if countryelection_FE == 45 & IMD3002_LH_PL == 2080003
replace type_PID = 7 if countryelection_FE == 45 & PID_who == 2080003

replace party_voted = 32 if countryelection_FE == 45 & IMD3002_LH_PL == 2080004 //* Socialist People's Party
replace party_PID = 32 if countryelection_FE == 45 & PID_who == 2080004
replace type_voted = 1 if countryelection_FE == 45 & IMD3002_LH_PL == 2080004
replace type_PID = 1 if countryelection_FE == 45 & PID_who == 2080004

replace party_voted = 33 if countryelection_FE == 45 & IMD3002_LH_PL == 2080005 //* United Left
replace party_PID = 33 if countryelection_FE == 45 & PID_who == 2080005
replace type_voted = 4 if countryelection_FE == 45 & IMD3002_LH_PL == 2080005
replace type_PID = 4 if countryelection_FE == 45 & PID_who == 2080005

replace party_voted = 34 if countryelection_FE == 45 & IMD3002_LH_PL == 2080006 //* Social Libs
replace party_PID = 34 if countryelection_FE == 45 & PID_who == 2080006
replace type_voted = 1 if countryelection_FE == 45 & IMD3002_LH_PL == 2080006
replace type_PID = 1 if countryelection_FE == 45 & PID_who == 2080006

replace party_voted = 35 if countryelection_FE == 45 & IMD3002_LH_PL == 2080007 //* Conservative People's Party
replace party_PID = 35 if countryelection_FE == 45 & PID_who == 2080007
replace type_voted = 1 if countryelection_FE == 45 & IMD3002_LH_PL == 2080007
replace type_PID = 1 if countryelection_FE == 45 & PID_who == 2080007

replace party_voted = 36 if countryelection_FE == 45 & IMD3002_LH_PL == 2080008 //* Christian Democrats
replace party_PID = 36 if countryelection_FE == 45 & PID_who == 2080008
replace type_voted = 1 if countryelection_FE == 45 & IMD3002_LH_PL == 2080008
replace type_PID = 1 if countryelection_FE == 45 & PID_who == 2080008

replace party_voted = 38 if countryelection_FE == 45 & IMD3002_LH_PL == 2080010 //* Danish People's Party
replace party_PID = 38 if countryelection_FE == 45 & PID_who == 2080010
replace type_voted = 5 if countryelection_FE == 45 & IMD3002_LH_PL == 2080010
replace type_PID = 5 if countryelection_FE == 45 & PID_who == 2080010

replace party_voted = 39 if countryelection_FE == 45 & IMD3002_LH_PL == 2080011 //* Centre Democrats
replace party_PID = 39 if countryelection_FE == 45 & PID_who == 2080011
replace type_voted = 1 if countryelection_FE == 45 & IMD3002_LH_PL == 2080011
replace type_PID = 1 if countryelection_FE == 45 & PID_who == 2080011

replace party_voted = 40 if countryelection_FE == 45 & IMD3002_LH_PL == 2080014 //* Democratic Renewal
replace party_PID = 40 if countryelection_FE == 45 & PID_who == 2080014
replace type_voted = 6 if countryelection_FE == 45 & IMD3002_LH_PL == 2080014
replace type_PID = 6 if countryelection_FE == 45 & PID_who == 2080014

replace party_voted = 37 if countryelection_FE == 45 & IMD3002_LH_PL == 2080009 //* New Alliance
replace party_PID = 37 if countryelection_FE == 45 & PID_who == 2080009
replace type_voted = 3 if countryelection_FE == 45 & IMD3002_LH_PL == 2080009
replace type_PID = 3 if countryelection_FE == 45 & PID_who == 2080009



//* Spain 1996

replace incumbent_voted = 1 if countryelection_FE == 46 & inlist(IMD3002_LH_PL,7240001) //* PSOE
replace incumbent_PID = 1 if countryelection_FE == 46 & inlist(PID_who,7240001)

replace party_voted = 175 if countryelection_FE == 46 & IMD3002_LH_PL == 7240001 //*PSOE
replace party_PID = 175 if countryelection_FE == 46 & PID_who == 7240001
replace type_voted = 1 if countryelection_FE == 46 & IMD3002_LH_PL == 7240001
replace type_PID = 1 if countryelection_FE == 46 & PID_who == 7240001

replace party_voted = 176 if countryelection_FE == 46 & IMD3002_LH_PL == 7240002 //*People's Party
replace party_PID = 176 if countryelection_FE == 46 & PID_who == 7240002
replace type_voted = 1 if countryelection_FE == 46 & IMD3002_LH_PL == 7240002
replace type_PID = 1 if countryelection_FE == 46 & PID_who == 7240002

replace party_voted = 177 if countryelection_FE == 46 & IMD3002_LH_PL == 7240003 //* Convergence and Union
replace party_PID = 177 if countryelection_FE == 46 & PID_who == 7240003
replace type_voted = 1 if countryelection_FE == 46 & IMD3002_LH_PL == 7240003
replace type_PID = 1 if countryelection_FE == 46 & PID_who == 7240003

replace party_voted = 178 if countryelection_FE == 46 & IMD3002_LH_PL == 7240004 //* United Left
replace party_PID = 178 if countryelection_FE == 46 & PID_who == 7240004
replace type_voted = 6 if countryelection_FE == 46 & IMD3002_LH_PL == 7240004
replace type_PID = 6 if countryelection_FE == 46 & PID_who == 7240004

replace party_voted = 179 if countryelection_FE == 46 & IMD3002_LH_PL == 7240005 //* Basque Nationalist
replace party_PID = 179 if countryelection_FE == 46 & PID_who == 7240005
replace type_voted = 4 if countryelection_FE == 46 & IMD3002_LH_PL == 7240005
replace type_PID = 4 if countryelection_FE == 46 & PID_who == 7240005

replace party_voted = 180 if countryelection_FE == 46 & IMD3002_LH_PL == 7240008 //* Galician Nationalist Bloc
replace party_PID = 180 if countryelection_FE == 46 & PID_who == 7240008
replace type_voted = 6 if countryelection_FE == 46 & IMD3002_LH_PL == 7240008
replace type_PID = 6 if countryelection_FE == 46 & PID_who == 7240008

replace party_voted = 181 if countryelection_FE == 46 & IMD3002_LH_PL == 7240009 //* Republican Left of Catalonia
replace party_PID = 181 if countryelection_FE == 46 & PID_who == 7240009
replace type_voted = 6 if countryelection_FE == 46 & IMD3002_LH_PL == 7240009
replace type_PID = 6 if countryelection_FE == 46 & PID_who == 7240009

replace party_voted = 185 if countryelection_FE == 46 & IMD3002_LH_PL == 7240017 //* Ecologists
replace party_PID = 185 if countryelection_FE == 46 & PID_who == 7240017
replace type_voted = 6 if countryelection_FE == 46 & IMD3002_LH_PL == 7240017
replace type_PID = 6 if countryelection_FE == 46 & PID_who == 7240017

replace party_voted = 186 if countryelection_FE == 46 & IMD3002_LH_PL == 7240026 //* Aragonese Party
replace party_PID = 186 if countryelection_FE == 46 & PID_who == 7240026
replace type_voted = 1 if countryelection_FE == 46 & IMD3002_LH_PL == 7240026
replace type_PID = 1 if countryelection_FE == 46 & PID_who == 7240026

replace party_voted = 188 if countryelection_FE == 46 & IMD3002_LH_PL == 7240028 //* Herri Batasuna
replace party_PID = 188 if countryelection_FE == 46 & PID_who == 7240028
replace type_voted = 6 if countryelection_FE == 46 & IMD3002_LH_PL == 7240028
replace type_PID = 6 if countryelection_FE == 46 & PID_who == 7240028

replace party_voted = 189 if countryelection_FE == 46 & IMD3002_LH_PL == 7240032 //* Valencian Union
replace party_PID = 189 if countryelection_FE == 46 & PID_who == 7240032
replace type_voted = 1 if countryelection_FE == 46 & IMD3002_LH_PL == 7240032
replace type_PID = 1 if countryelection_FE == 46 & PID_who == 7240032

replace party_voted = 192 if countryelection_FE == 46 & IMD3002_LH_PL == 7240050 //* Andalusian Party
replace party_PID = 192 if countryelection_FE == 46 & PID_who == 7240050
replace type_voted = 4 if countryelection_FE == 46 & IMD3002_LH_PL == 7240050
replace type_PID = 4 if countryelection_FE == 46 & PID_who == 7240050

replace party_voted = 182 if countryelection_FE == 46 & IMD3002_LH_PL == 7240010 //* Basque Solidarity
replace party_PID = 182 if countryelection_FE == 46 & PID_who == 7240010
replace type_voted = 6 if countryelection_FE == 46 & IMD3002_LH_PL == 7240010
replace type_PID = 6 if countryelection_FE == 46 & PID_who == 7240010

replace party_voted = 184 if countryelection_FE == 46 & IMD3002_LH_PL == 7240013 //* Canarian Coalition
replace party_PID = 184 if countryelection_FE == 46 & PID_who == 7240013
replace type_voted = 1 if countryelection_FE == 46 & IMD3002_LH_PL == 7240013
replace type_PID = 1 if countryelection_FE == 46 & PID_who == 7240013

replace party_voted = 344 if countryelection_FE == 46 & IMD3002_LH_PL == 7240015 //* Canarian Independents
replace party_PID = 344 if countryelection_FE == 46 & PID_who == 7240015
replace type_voted = 6 if countryelection_FE == 46 & IMD3002_LH_PL == 7240015
replace type_PID = 6 if countryelection_FE == 46 & PID_who == 7240015

replace party_voted = 335 if countryelection_FE == 46 & IMD3002_LH_PL == 7240034 //* Mallorcan PSOE
replace party_PID = 335 if countryelection_FE == 46 & PID_who == 7240034
replace type_voted = 1 if countryelection_FE == 46 & IMD3002_LH_PL == 7240034
replace type_PID = 1 if countryelection_FE == 46 & PID_who == 7240034


//* Spain 2000

replace incumbent_voted = 1 if countryelection_FE == 47 & inlist(IMD3002_LH_PL,7240002) //* PP
replace incumbent_PID = 1 if countryelection_FE == 47 & inlist(PID_who,7240002)

replace party_voted = 175 if countryelection_FE == 47 & IMD3002_LH_PL == 7240001 //*PSOE
replace party_PID = 175 if countryelection_FE == 47 & PID_who == 7240001
replace type_voted = 1 if countryelection_FE == 47 & IMD3002_LH_PL == 7240001
replace type_PID = 1 if countryelection_FE == 47 & PID_who == 7240001

replace party_voted = 176 if countryelection_FE == 47 & IMD3002_LH_PL == 7240002 //*People's Party
replace party_PID = 176 if countryelection_FE == 47 & PID_who == 7240002
replace type_voted = 1 if countryelection_FE == 47 & IMD3002_LH_PL == 7240002
replace type_PID = 1 if countryelection_FE == 47 & PID_who == 7240002

replace party_voted = 177 if countryelection_FE == 47 & IMD3002_LH_PL == 7240003 //* Convergence and Union
replace party_PID = 177 if countryelection_FE == 47 & PID_who == 7240003
replace type_voted = 1 if countryelection_FE == 47 & IMD3002_LH_PL == 7240003
replace type_PID = 1 if countryelection_FE == 47 & PID_who == 7240003

replace party_voted = 178 if countryelection_FE == 47 & IMD3002_LH_PL == 7240004 //* United Left
replace party_PID = 178 if countryelection_FE == 47 & PID_who == 7240004
replace type_voted = 4 if countryelection_FE == 47 & IMD3002_LH_PL == 7240004
replace type_PID = 4 if countryelection_FE == 47 & PID_who == 7240004

replace party_voted = 179 if countryelection_FE == 47 & IMD3002_LH_PL == 7240005 //* Basque Nationalist
replace party_PID = 179 if countryelection_FE == 47 & PID_who == 7240005
replace type_voted = 4 if countryelection_FE == 47 & IMD3002_LH_PL == 7240005
replace type_PID = 4 if countryelection_FE == 47 & PID_who == 7240005

replace party_voted = 180 if countryelection_FE == 47 & IMD3002_LH_PL == 7240008 //* Galician Nationalist Bloc
replace party_PID = 180 if countryelection_FE == 47 & PID_who == 7240008
replace type_voted = 6 if countryelection_FE == 47 & IMD3002_LH_PL == 7240008
replace type_PID = 6 if countryelection_FE == 47 & PID_who == 7240008

replace party_voted = 181 if countryelection_FE == 47 & IMD3002_LH_PL == 7240009 //* Republican Left of Catalonia
replace party_PID = 181 if countryelection_FE == 47 & PID_who == 7240009
replace type_voted = 6 if countryelection_FE == 47 & IMD3002_LH_PL == 7240009
replace type_PID = 6 if countryelection_FE == 47 & PID_who == 7240009

replace party_voted = 185 if countryelection_FE == 47 & IMD3002_LH_PL == 7240017 //* Ecologists
replace party_PID = 185 if countryelection_FE == 47 & PID_who == 7240017
replace type_voted = 6 if countryelection_FE == 47 & IMD3002_LH_PL == 7240017
replace type_PID = 6 if countryelection_FE == 47 & PID_who == 7240017

replace party_voted = 186 if countryelection_FE == 47 & IMD3002_LH_PL == 7240026 //* Aragonese Party
replace party_PID = 186 if countryelection_FE == 47 & PID_who == 7240026
replace type_voted = 2 if countryelection_FE == 47 & IMD3002_LH_PL == 7240026
replace type_PID = 2 if countryelection_FE == 47 & PID_who == 7240026

replace party_voted = 188 if countryelection_FE == 47 & IMD3002_LH_PL == 7240028 //* Herri Batasuna
replace party_PID = 188 if countryelection_FE == 47 & PID_who == 7240028
replace type_voted = 6 if countryelection_FE == 47 & IMD3002_LH_PL == 7240028
replace type_PID = 6 if countryelection_FE == 47 & PID_who == 7240028

replace party_voted = 189 if countryelection_FE == 47 & IMD3002_LH_PL == 7240032 //* Valencian Union
replace party_PID = 189 if countryelection_FE == 47 & PID_who == 7240032
replace type_voted = 1 if countryelection_FE == 47 & IMD3002_LH_PL == 7240032
replace type_PID = 1 if countryelection_FE == 47 & PID_who == 7240032

replace party_voted = 192 if countryelection_FE == 47 & IMD3002_LH_PL == 7240050 //* Andalusian Party
replace party_PID = 192 if countryelection_FE == 47 & PID_who == 7240050
replace type_voted = 2 if countryelection_FE == 47 & IMD3002_LH_PL == 7240050
replace type_PID = 2 if countryelection_FE == 47 & PID_who == 7240050

replace party_voted = 182 if countryelection_FE == 47 & IMD3002_LH_PL == 7240010 //* Basque Solidarity
replace party_PID = 182 if countryelection_FE == 47 & PID_who == 7240010
replace type_voted = 6 if countryelection_FE == 47 & IMD3002_LH_PL == 7240010
replace type_PID = 6 if countryelection_FE == 47 & PID_who == 7240010

replace party_voted = 184 if countryelection_FE == 47 & IMD3002_LH_PL == 7240013 //* Canarian Coalition
replace party_PID = 184 if countryelection_FE == 47 & PID_who == 7240013
replace type_voted = 1 if countryelection_FE == 47 & IMD3002_LH_PL == 7240013
replace type_PID = 1 if countryelection_FE == 47 & PID_who == 7240013

replace party_voted = 344 if countryelection_FE == 47 & IMD3002_LH_PL == 7240015 //* Canarian Independents
replace party_PID = 344 if countryelection_FE == 47 & PID_who == 7240015
replace type_voted = 6 if countryelection_FE == 47 & IMD3002_LH_PL == 7240015
replace type_PID = 6 if countryelection_FE == 47 & PID_who == 7240015

replace party_voted = 335 if countryelection_FE == 47 & IMD3002_LH_PL == 7240034 //* Mallorcan PSOE
replace party_PID = 335 if countryelection_FE == 47 & PID_who == 7240034
replace type_voted = 1 if countryelection_FE == 47 & IMD3002_LH_PL == 7240034
replace type_PID = 1 if countryelection_FE == 47 & PID_who == 7240034

replace party_voted = 190 if countryelection_FE == 47 & IMD3002_LH_PL == 7240042 //* Navarrese People's Union
replace party_PID = 190 if countryelection_FE == 47 & PID_who == 7240042
replace type_voted = 1 if countryelection_FE == 47 & IMD3002_LH_PL == 7240042
replace type_PID = 1 if countryelection_FE == 47 & PID_who == 7240042


//* Spain 2004

replace incumbent_voted = 1 if countryelection_FE == 48 & inlist(IMD3002_LH_PL,7240002) //* PP
replace incumbent_PID = 1 if countryelection_FE == 48 & inlist(PID_who,7240002)

replace party_voted = 175 if countryelection_FE == 48 & IMD3002_LH_PL == 7240001 //*PSOE
replace party_PID = 175 if countryelection_FE == 48 & PID_who == 7240001
replace type_voted = 1 if countryelection_FE == 48 & IMD3002_LH_PL == 7240001
replace type_PID = 1 if countryelection_FE == 48 & PID_who == 7240001

replace party_voted = 176 if countryelection_FE == 48 & IMD3002_LH_PL == 7240002 //*People's Party
replace party_PID = 176 if countryelection_FE == 48 & PID_who == 7240002
replace type_voted = 1 if countryelection_FE == 48 & IMD3002_LH_PL == 7240002
replace type_PID = 1 if countryelection_FE == 48 & PID_who == 7240002

replace party_voted = 177 if countryelection_FE == 48 & IMD3002_LH_PL == 7240003 //* Convergence and Union
replace party_PID = 177 if countryelection_FE == 48 & PID_who == 7240003
replace type_voted = 1 if countryelection_FE == 48 & IMD3002_LH_PL == 7240003
replace type_PID = 1 if countryelection_FE == 48 & PID_who == 7240003

replace party_voted = 178 if countryelection_FE == 48 & IMD3002_LH_PL == 7240004 //* United Left
replace party_PID = 178 if countryelection_FE == 48 & PID_who == 7240004
replace type_voted = 4 if countryelection_FE == 48 & IMD3002_LH_PL == 7240004
replace type_PID = 4 if countryelection_FE == 48 & PID_who == 7240004

replace party_voted = 179 if countryelection_FE == 48 & IMD3002_LH_PL == 7240005 //* Basque Nationalist
replace party_PID = 179 if countryelection_FE == 48 & PID_who == 7240005
replace type_voted = 4 if countryelection_FE == 48 & IMD3002_LH_PL == 7240005
replace type_PID = 4 if countryelection_FE == 48 & PID_who == 7240005

replace party_voted = 180 if countryelection_FE == 48 & IMD3002_LH_PL == 7240008 //* Galician Nationalist Bloc
replace party_PID = 180 if countryelection_FE == 48 & PID_who == 7240008
replace type_voted = 6 if countryelection_FE == 48 & IMD3002_LH_PL == 7240008
replace type_PID = 6 if countryelection_FE == 48 & PID_who == 7240008

replace party_voted = 181 if countryelection_FE == 48 & IMD3002_LH_PL == 7240009 //* Republican Left of Catalonia
replace party_PID = 181 if countryelection_FE == 48 & PID_who == 7240009
replace type_voted = 6 if countryelection_FE == 48 & IMD3002_LH_PL == 7240009
replace type_PID = 6 if countryelection_FE == 48 & PID_who == 7240009

replace party_voted = 185 if countryelection_FE == 48 & IMD3002_LH_PL == 7240017 //* Ecologists
replace party_PID = 185 if countryelection_FE == 48 & PID_who == 7240017
replace type_voted = 6 if countryelection_FE == 48 & IMD3002_LH_PL == 7240017
replace type_PID = 6 if countryelection_FE == 48 & PID_who == 7240017

replace party_voted = 186 if countryelection_FE == 48 & IMD3002_LH_PL == 7240026 //* Aragonese Party
replace party_PID = 186 if countryelection_FE == 48 & PID_who == 7240026
replace type_voted = 2 if countryelection_FE == 48 & IMD3002_LH_PL == 7240026
replace type_PID = 2 if countryelection_FE == 48 & PID_who == 7240026

replace party_voted = 188 if countryelection_FE == 48 & IMD3002_LH_PL == 7240028 //* Herri Batasuna
replace party_PID = 188 if countryelection_FE == 48 & PID_who == 7240028
replace type_voted = 6 if countryelection_FE == 48 & IMD3002_LH_PL == 7240028
replace type_PID = 6 if countryelection_FE == 48 & PID_who == 7240028

replace party_voted = 189 if countryelection_FE == 48 & IMD3002_LH_PL == 7240032 //* Valencian Union
replace party_PID = 189 if countryelection_FE == 48 & PID_who == 7240032
replace type_voted = 1 if countryelection_FE == 48 & IMD3002_LH_PL == 7240032
replace type_PID = 1 if countryelection_FE == 48 & PID_who == 7240032

replace party_voted = 192 if countryelection_FE == 48 & IMD3002_LH_PL == 7240050 //* Andalusian Party
replace party_PID = 192 if countryelection_FE == 48 & PID_who == 7240050
replace type_voted = 4 if countryelection_FE == 48 & IMD3002_LH_PL == 7240050
replace type_PID = 4 if countryelection_FE == 48 & PID_who == 7240050

replace party_voted = 182 if countryelection_FE == 48 & IMD3002_LH_PL == 7240010 //* Basque Solidarity
replace party_PID = 182 if countryelection_FE == 48 & PID_who == 7240010
replace type_voted = 6 if countryelection_FE == 48 & IMD3002_LH_PL == 7240010
replace type_PID = 6 if countryelection_FE == 48 & PID_who == 7240010

replace party_voted = 184 if countryelection_FE == 48 & IMD3002_LH_PL == 7240013 //* Canarian Coalition
replace party_PID = 184 if countryelection_FE == 48 & PID_who == 7240013
replace type_voted = 1 if countryelection_FE == 48 & IMD3002_LH_PL == 7240013
replace type_PID = 1 if countryelection_FE == 48 & PID_who == 7240013

replace party_voted = 344 if countryelection_FE == 48 & IMD3002_LH_PL == 7240015 //* Canarian Independents
replace party_PID = 344 if countryelection_FE == 48 & PID_who == 7240015
replace type_voted = 6 if countryelection_FE == 48 & IMD3002_LH_PL == 7240015
replace type_PID = 6 if countryelection_FE == 48 & PID_who == 7240015

replace party_voted = 335 if countryelection_FE == 48 & IMD3002_LH_PL == 7240034 //* Mallorcan PSOE
replace party_PID = 335 if countryelection_FE == 48 & PID_who == 7240034
replace type_voted = 1 if countryelection_FE == 48 & IMD3002_LH_PL == 7240034
replace type_PID = 1 if countryelection_FE == 48 & PID_who == 7240034

replace party_voted = 190 if countryelection_FE == 48 & IMD3002_LH_PL == 7240042 //* Navarrese People's Union
replace party_PID = 190 if countryelection_FE == 48 & PID_who == 7240042
replace type_voted = 1 if countryelection_FE == 48 & IMD3002_LH_PL == 7240042
replace type_PID = 1 if countryelection_FE == 48 & PID_who == 7240042

replace party_voted = 191 if countryelection_FE == 48 & IMD3002_LH_PL == 7240045 //* Aragonese Council
replace party_PID = 191 if countryelection_FE == 48 & PID_who == 7240045
replace type_voted = 3 if countryelection_FE == 48 & IMD3002_LH_PL == 7240045
replace type_PID = 3 if countryelection_FE == 48 & PID_who == 7240045


//* Spain 2008

replace incumbent_voted = 1 if countryelection_FE == 49 & inlist(IMD3002_LH_PL,7240001)  //* PSOE
replace incumbent_PID = 1 if countryelection_FE == 49 & inlist(PID_who,7240001)

replace party_voted = 175 if countryelection_FE == 49 & IMD3002_LH_PL == 7240001 //*PSOE
replace party_PID = 175 if countryelection_FE == 49 & PID_who == 7240001
replace type_voted = 1 if countryelection_FE == 49 & IMD3002_LH_PL == 7240001
replace type_PID = 1 if countryelection_FE == 49 & PID_who == 7240001

replace party_voted = 176 if countryelection_FE == 49 & IMD3002_LH_PL == 7240002 //*People's Party
replace party_PID = 176 if countryelection_FE == 49 & PID_who == 7240002
replace type_voted = 1 if countryelection_FE == 49 & IMD3002_LH_PL == 7240002
replace type_PID = 1 if countryelection_FE == 49 & PID_who == 7240002

replace party_voted = 177 if countryelection_FE == 49 & IMD3002_LH_PL == 7240003 //* Convergence and Union
replace party_PID = 177 if countryelection_FE == 49 & PID_who == 7240003
replace type_voted = 1 if countryelection_FE == 49 & IMD3002_LH_PL == 7240003
replace type_PID = 1 if countryelection_FE == 49 & PID_who == 7240003

replace party_voted = 178 if countryelection_FE == 49 & IMD3002_LH_PL == 7240004 //* United Left
replace party_PID = 178 if countryelection_FE == 49 & PID_who == 7240004
replace type_voted = 4 if countryelection_FE == 49 & IMD3002_LH_PL == 7240004
replace type_PID = 4 if countryelection_FE == 49 & PID_who == 7240004

replace party_voted = 179 if countryelection_FE == 49 & IMD3002_LH_PL == 7240005 //* Basque Nationalist
replace party_PID = 179 if countryelection_FE == 49 & PID_who == 7240005
replace type_voted = 4 if countryelection_FE == 49 & IMD3002_LH_PL == 7240005
replace type_PID = 4 if countryelection_FE == 49 & PID_who == 7240005

replace party_voted = 180 if countryelection_FE == 49 & IMD3002_LH_PL == 7240008 //* Galician Nationalist Bloc
replace party_PID = 180 if countryelection_FE == 49 & PID_who == 7240008
replace type_voted = 4 if countryelection_FE == 49 & IMD3002_LH_PL == 7240008
replace type_PID = 4 if countryelection_FE == 49 & PID_who == 7240008

replace party_voted = 181 if countryelection_FE == 49 & IMD3002_LH_PL == 7240009 //* Republican Left of Catalonia
replace party_PID = 181 if countryelection_FE == 49 & PID_who == 7240009
replace type_voted = 4 if countryelection_FE == 49 & IMD3002_LH_PL == 7240009
replace type_PID = 4 if countryelection_FE == 49 & PID_who == 7240009

replace party_voted = 183 if countryelection_FE == 49 & IMD3002_LH_PL == 7240012 //* Union, Progress, and Democracy
replace party_PID = 183 if countryelection_FE == 49 & PID_who == 7240012
replace type_voted = 2 if countryelection_FE == 49 & IMD3002_LH_PL == 7240012
replace type_PID = 2 if countryelection_FE == 49 & PID_who == 7240012

replace party_voted = 185 if countryelection_FE == 49 & IMD3002_LH_PL == 7240017 //* Ecologists
replace party_PID = 185 if countryelection_FE == 49 & PID_who == 7240017
replace type_voted = 6 if countryelection_FE == 49 & IMD3002_LH_PL == 7240017
replace type_PID = 6 if countryelection_FE == 49 & PID_who == 7240017

replace party_voted = 186 if countryelection_FE == 49 & IMD3002_LH_PL == 7240026 //* Aragonese Party
replace party_PID = 186 if countryelection_FE == 49 & PID_who == 7240026
replace type_voted = 3 if countryelection_FE == 49 & IMD3002_LH_PL == 7240026
replace type_PID = 3 if countryelection_FE == 49 & PID_who == 7240026

replace party_voted = 345 if countryelection_FE == 49 & IMD3002_LH_PL == 7240027 //* Nafarroa Bai (Navarre Yes)
replace party_PID = 345 if countryelection_FE == 49 & PID_who == 7240027
replace type_voted = 6 if countryelection_FE == 49 & IMD3002_LH_PL == 7240027
replace type_PID = 6 if countryelection_FE == 49 & PID_who == 7240027

replace party_voted = 188 if countryelection_FE == 49 & IMD3002_LH_PL == 7240028 //* Herri Batasuna
replace party_PID = 188 if countryelection_FE == 49 & PID_who == 7240028
replace type_voted = 4 if countryelection_FE == 49 & IMD3002_LH_PL == 7240028
replace type_PID = 4 if countryelection_FE == 49 & PID_who == 7240028

replace party_voted = 189 if countryelection_FE == 49 & IMD3002_LH_PL == 7240032 //* Valencian Union
replace party_PID = 189 if countryelection_FE == 49 & PID_who == 7240032
replace type_voted = 1 if countryelection_FE == 49 & IMD3002_LH_PL == 7240032
replace type_PID = 1 if countryelection_FE == 49 & PID_who == 7240032

replace party_voted = 192 if countryelection_FE == 49 & IMD3002_LH_PL == 7240050 //* Andalusian Party
replace party_PID = 192 if countryelection_FE == 49 & PID_who == 7240050
replace type_voted = 4 if countryelection_FE == 49 & IMD3002_LH_PL == 7240050
replace type_PID = 4 if countryelection_FE == 49 & PID_who == 7240050

replace party_voted = 182 if countryelection_FE == 49 & IMD3002_LH_PL == 7240010 //* Basque Solidarity
replace party_PID = 182 if countryelection_FE == 49 & PID_who == 7240010
replace type_voted = 6 if countryelection_FE == 49 & IMD3002_LH_PL == 7240010
replace type_PID = 6 if countryelection_FE == 49 & PID_who == 7240010

replace party_voted = 184 if countryelection_FE == 49 & IMD3002_LH_PL == 7240013 | countryelection_FE == 49 & IMD3002_LH_PL == 7240014 //* Canarian Coalition
replace party_PID = 184 if countryelection_FE == 49 & PID_who == 7240013 |  countryelection_FE == 49 & PID_who == 7240014
replace type_voted = 1 if countryelection_FE == 49 & IMD3002_LH_PL == 7240013 | countryelection_FE == 49 & IMD3002_LH_PL == 7240014
replace type_PID = 1 if countryelection_FE == 49 & PID_who == 7240013 | countryelection_FE == 49 & PID_who == 7240014

replace party_voted = 344 if countryelection_FE == 49 & IMD3002_LH_PL == 7240015 //* Canarian Independents
replace party_PID = 344 if countryelection_FE == 49 & PID_who == 7240015
replace type_voted = 6 if countryelection_FE == 49 & IMD3002_LH_PL == 7240015
replace type_PID = 6 if countryelection_FE == 49 & PID_who == 7240015

replace party_voted = 335 if countryelection_FE == 49 & IMD3002_LH_PL == 7240034 //* Mallorcan PSOE
replace party_PID = 335 if countryelection_FE == 49 & PID_who == 7240034
replace type_voted = 1 if countryelection_FE == 49 & IMD3002_LH_PL == 7240034
replace type_PID = 1 if countryelection_FE == 49 & PID_who == 7240034

replace party_voted = 190 if countryelection_FE == 49 & IMD3002_LH_PL == 7240042 //* Navarrese People's Union
replace party_PID = 190 if countryelection_FE == 49 & PID_who == 7240042
replace type_voted = 1 if countryelection_FE == 49 & IMD3002_LH_PL == 7240042
replace type_PID = 1 if countryelection_FE == 49 & PID_who == 7240042

replace party_voted = 191 if countryelection_FE == 49 & IMD3002_LH_PL == 7240045 //* Aragonese Council
replace party_PID = 191 if countryelection_FE == 49 & PID_who == 7240045
replace type_voted = 3 if countryelection_FE == 49 & IMD3002_LH_PL == 7240045
replace type_PID = 3 if countryelection_FE == 49 & PID_who == 7240045

//* Finland 2003

replace incumbent_voted = 1 if countryelection_FE == 51 & inlist(IMD3002_LH_PL,2460002,2460003,2460005,2460006,2460008)  //* KoK - SDP - Greens - SPP - Left Alliance
replace incumbent_PID = 1 if countryelection_FE == 51 & inlist(PID_who,2460002,2460003,2460005,2460006,2460008)

replace party_voted = 41 if countryelection_FE == 51 & IMD3002_LH_PL == 2460001 //* Centre Party (KESK)
replace party_PID = 41 if countryelection_FE == 51 & PID_who == 2460001
replace type_voted = 1 if countryelection_FE == 51 & IMD3002_LH_PL == 2460001
replace type_PID = 1 if countryelection_FE == 51 & PID_who == 2460001

replace party_voted = 42 if countryelection_FE == 51 & IMD3002_LH_PL == 2460002 //* SDP
replace party_PID = 42 if countryelection_FE == 51 & PID_who == 2460002
replace type_voted = 1 if countryelection_FE == 51 & IMD3002_LH_PL == 2460002
replace type_PID = 1 if countryelection_FE == 51 & PID_who == 2460002

replace party_voted = 43 if countryelection_FE == 51 & IMD3002_LH_PL == 2460003 //* KoK (National Coalition)
replace party_PID = 43 if countryelection_FE == 51 & PID_who == 2460003
replace type_voted = 1 if countryelection_FE == 51 & IMD3002_LH_PL == 2460003
replace type_PID = 1 if countryelection_FE == 51 & PID_who == 2460003

replace party_voted = 44 if countryelection_FE == 51 & IMD3002_LH_PL == 2460004 //* True Finns
replace party_PID = 44 if countryelection_FE == 51 & PID_who == 2460004
replace type_voted = 7 if countryelection_FE == 51 & IMD3002_LH_PL == 2460004
replace type_PID = 7 if countryelection_FE == 51 & PID_who == 2460004

replace party_voted = 45 if countryelection_FE == 51 & IMD3002_LH_PL == 2460005 //* Green League
replace party_PID = 45 if countryelection_FE == 51 & PID_who == 2460005
replace type_voted = 1 if countryelection_FE == 51 & IMD3002_LH_PL == 2460005
replace type_PID = 1 if countryelection_FE == 51 & PID_who == 2460005

replace party_voted = 46 if countryelection_FE == 51 & IMD3002_LH_PL == 2460006 //* Left Alliance
replace party_PID = 46 if countryelection_FE == 51 & PID_who == 2460006
replace type_voted = 4 if countryelection_FE == 51 & IMD3002_LH_PL == 2460006
replace type_PID = 4 if countryelection_FE == 51 & PID_who == 2460006

replace party_voted = 47 if countryelection_FE == 51 & IMD3002_LH_PL == 2460007 //* Christian Democrats
replace party_PID = 47 if countryelection_FE == 51 & PID_who == 2460007
replace type_voted = 1 if countryelection_FE == 51 & IMD3002_LH_PL == 2460007
replace type_PID = 1 if countryelection_FE == 51 & PID_who == 2460007

replace party_voted = 48 if countryelection_FE == 51 & IMD3002_LH_PL == 2460008 // *Swedish People's Party
replace party_PID = 48 if countryelection_FE == 51 & PID_who == 2460008
replace type_voted = 1 if countryelection_FE == 51 & IMD3002_LH_PL == 2460008
replace type_PID = 1 if countryelection_FE == 51 & PID_who == 2460008



//* Finland 2007

replace incumbent_voted = 1 if countryelection_FE == 52 & inlist(IMD3002_LH_PL,2460001, 2460002,2460008)  //* KESK-SDP-SPP
replace incumbent_PID = 1 if countryelection_FE == 52 & inlist(PID_who,2460001, 2460002,2460008)

replace party_voted = 41 if countryelection_FE == 52 & IMD3002_LH_PL == 2460001 //* Centre Party (KESK)
replace party_PID = 41 if countryelection_FE == 52 & PID_who == 2460001
replace type_voted = 1 if countryelection_FE == 52 & IMD3002_LH_PL == 2460001
replace type_PID = 1 if countryelection_FE == 52 & PID_who == 2460001

replace party_voted = 42 if countryelection_FE == 52 & IMD3002_LH_PL == 2460002 //* SDP
replace party_PID = 42 if countryelection_FE == 52 & PID_who == 2460002
replace type_voted = 1 if countryelection_FE == 52 & IMD3002_LH_PL == 2460002
replace type_PID = 1 if countryelection_FE == 52 & PID_who == 2460002

replace party_voted = 43 if countryelection_FE == 52 & IMD3002_LH_PL == 2460003 //* KoK (National Coalition)
replace party_PID = 43 if countryelection_FE == 52 & PID_who == 2460003
replace type_voted = 1 if countryelection_FE == 52 & IMD3002_LH_PL == 2460003
replace type_PID = 1 if countryelection_FE == 52 & PID_who == 2460003

replace party_voted = 44 if countryelection_FE == 52 & IMD3002_LH_PL == 2460004 //* True Finns
replace party_PID = 44 if countryelection_FE == 52 & PID_who == 2460004
replace type_voted = 7 if countryelection_FE == 52 & IMD3002_LH_PL == 2460004
replace type_PID = 7 if countryelection_FE == 52 & PID_who == 2460004

replace party_voted = 45 if countryelection_FE == 52 & IMD3002_LH_PL == 2460005 //* Green League
replace party_PID = 45 if countryelection_FE == 52 & PID_who == 2460005
replace type_voted = 1 if countryelection_FE == 52 & IMD3002_LH_PL == 2460005
replace type_PID = 1 if countryelection_FE == 52 & PID_who == 2460005

replace party_voted = 46 if countryelection_FE == 52 & IMD3002_LH_PL == 2460006 //* Left Alliance
replace party_PID = 46 if countryelection_FE == 52 & PID_who == 2460006
replace type_voted = 4 if countryelection_FE == 52 & IMD3002_LH_PL == 2460006
replace type_PID = 4 if countryelection_FE == 52 & PID_who == 2460006

replace party_voted = 47 if countryelection_FE == 52 & IMD3002_LH_PL == 2460007 //* Christian Democrats
replace party_PID = 47 if countryelection_FE == 52 & PID_who == 2460007
replace type_voted = 1 if countryelection_FE == 52 & IMD3002_LH_PL == 2460007
replace type_PID = 1 if countryelection_FE == 52 & PID_who == 2460007

replace party_voted = 48 if countryelection_FE == 52 & IMD3002_LH_PL == 2460008 // *Swedish People's Party
replace party_PID = 48 if countryelection_FE == 52 & PID_who == 2460008
replace type_voted = 1 if countryelection_FE == 52 & IMD3002_LH_PL == 2460008
replace type_PID = 1 if countryelection_FE == 52 & PID_who == 2460008

replace party_voted = 49 if countryelection_FE == 52 & IMD3002_LH_PL == 2460009 // *Independence Party
replace party_PID = 49 if countryelection_FE == 52 & PID_who == 2460009
replace type_voted = 7 if countryelection_FE == 52 & IMD3002_LH_PL == 2460009
replace type_PID = 7 if countryelection_FE == 52 & PID_who == 2460009

replace party_voted = 50 if countryelection_FE == 52 & IMD3002_LH_PL == 2460013 // *For Peace and Socialism
replace party_PID = 50 if countryelection_FE == 52 & PID_who == 2460013
replace type_voted = 6 if countryelection_FE == 52 & IMD3002_LH_PL == 2460013
replace type_PID = 6 if countryelection_FE == 52 & PID_who == 2460013

replace party_voted = 51 if countryelection_FE == 52 & IMD3002_LH_PL == 2460014 // *Liberal People's Party
replace party_PID = 51 if countryelection_FE == 52 & PID_who == 2460014
replace type_voted = 1 if countryelection_FE == 52 & IMD3002_LH_PL == 2460014
replace type_PID = 1 if countryelection_FE == 52 & PID_who == 2460014

replace party_voted = 54 if countryelection_FE == 52 & IMD3002_LH_PL == 2460017 // *Finnish Senior Citizen's Party
replace party_PID = 54 if countryelection_FE == 52 & PID_who == 2460017
replace type_voted = 3 if countryelection_FE == 52 & IMD3002_LH_PL == 2460017
replace type_PID = 3 if countryelection_FE == 52 & PID_who == 2460017

replace party_voted = 55 if countryelection_FE == 52 & IMD3002_LH_PL == 2460018 // *Finnish Communist Party
replace party_PID = 55 if countryelection_FE == 52 & PID_who == 2460018
replace type_voted = 6 if countryelection_FE == 52 & IMD3002_LH_PL == 2460018
replace type_PID = 6 if countryelection_FE == 52 & PID_who == 2460018

replace party_voted = 56 if countryelection_FE == 52 & IMD3002_LH_PL == 2460020 // *Finnish Workers' Party
replace party_PID = 56 if countryelection_FE == 52 & PID_who == 2460020
replace type_voted = 6 if countryelection_FE == 52 & IMD3002_LH_PL == 2460020
replace type_PID = 6 if countryelection_FE == 52 & PID_who == 2460020



//* Finland 2011

replace incumbent_voted = 1 if countryelection_FE == 53 & inlist(IMD3002_LH_PL,2460001, 2460003, 2460005,2460008)  //* KESK-KOK-Greens-SPP
replace incumbent_PID = 1 if countryelection_FE == 53 & inlist(PID_who,2460001, 2460003, 2460005,2460008)

replace party_voted = 41 if countryelection_FE == 53 & IMD3002_LH_PL == 2460001 //* Centre Party (KESK)
replace party_PID = 41 if countryelection_FE == 53 & PID_who == 2460001
replace type_voted = 1 if countryelection_FE == 53 & IMD3002_LH_PL == 2460001
replace type_PID = 1 if countryelection_FE == 53 & PID_who == 2460001

replace party_voted = 42 if countryelection_FE == 53 & IMD3002_LH_PL == 2460002 //* SDP
replace party_PID = 42 if countryelection_FE == 53 & PID_who == 2460002
replace type_voted = 1 if countryelection_FE == 53 & IMD3002_LH_PL == 2460002
replace type_PID = 1 if countryelection_FE == 53 & PID_who == 2460002

replace party_voted = 43 if countryelection_FE == 53 & IMD3002_LH_PL == 2460003 //* KoK (National Coalition)
replace party_PID = 43 if countryelection_FE == 53 & PID_who == 2460003
replace type_voted = 1 if countryelection_FE == 53 & IMD3002_LH_PL == 2460003
replace type_PID = 1 if countryelection_FE == 53 & PID_who == 2460003

replace party_voted = 44 if countryelection_FE == 53 & IMD3002_LH_PL == 2460004 //* True Finns
replace party_PID = 44 if countryelection_FE == 53 & PID_who == 2460004
replace type_voted = 7 if countryelection_FE == 53 & IMD3002_LH_PL == 2460004
replace type_PID = 7 if countryelection_FE == 53 & PID_who == 2460004

replace party_voted = 45 if countryelection_FE == 53 & IMD3002_LH_PL == 2460005 //* Green League
replace party_PID = 45 if countryelection_FE == 53 & PID_who == 2460005
replace type_voted = 1 if countryelection_FE == 53 & IMD3002_LH_PL == 2460005
replace type_PID = 1 if countryelection_FE == 53 & PID_who == 2460005

replace party_voted = 46 if countryelection_FE == 53 & IMD3002_LH_PL == 2460006 //* Left Alliance
replace party_PID = 46 if countryelection_FE == 53 & PID_who == 2460006
replace type_voted = 4 if countryelection_FE == 53 & IMD3002_LH_PL == 2460006
replace type_PID = 4 if countryelection_FE == 53 & PID_who == 2460006

replace party_voted = 47 if countryelection_FE == 53 & IMD3002_LH_PL == 2460007 //* Christian Democrats
replace party_PID = 47 if countryelection_FE == 53 & PID_who == 2460007
replace type_voted = 1 if countryelection_FE == 53 & IMD3002_LH_PL == 2460007
replace type_PID = 1 if countryelection_FE == 53 & PID_who == 2460007

replace party_voted = 48 if countryelection_FE == 53 & IMD3002_LH_PL == 2460008 // *Swedish People's Party
replace party_PID = 48 if countryelection_FE == 53 & PID_who == 2460008
replace type_voted = 1 if countryelection_FE == 53 & IMD3002_LH_PL == 2460008
replace type_PID = 1 if countryelection_FE == 53 & PID_who == 2460008

replace party_voted = 49 if countryelection_FE == 53 & IMD3002_LH_PL == 2460009 // *Independence Party
replace party_PID = 49 if countryelection_FE == 53 & PID_who == 2460009
replace type_voted = 7 if countryelection_FE == 53 & IMD3002_LH_PL == 2460009
replace type_PID = 7 if countryelection_FE == 53 & PID_who == 2460009

replace party_voted = 50 if countryelection_FE == 53 & IMD3002_LH_PL == 2460013 // *For Peace and Socialism
replace party_PID = 50 if countryelection_FE == 53 & PID_who == 2460013
replace type_voted = 6 if countryelection_FE == 53 & IMD3002_LH_PL == 2460013
replace type_PID = 6 if countryelection_FE == 53 & PID_who == 2460013

replace party_voted = 51 if countryelection_FE == 53 & IMD3002_LH_PL == 2460014 // *Liberal People's Party
replace party_PID = 51 if countryelection_FE == 53 & PID_who == 2460014
replace type_voted = 1 if countryelection_FE == 53 & IMD3002_LH_PL == 2460014
replace type_PID = 1 if countryelection_FE == 53 & PID_who == 2460014

replace party_voted = 316 if countryelection_FE == 53 & IMD3002_LH_PL == 2460012 // *For the Poor
replace party_PID = 316 if countryelection_FE == 53 & PID_who == 2460012
replace type_voted = 2 if countryelection_FE == 53 & IMD3002_LH_PL == 2460012
replace type_PID = 2 if countryelection_FE == 53 & PID_who == 2460012

replace party_voted = 316 if countryelection_FE == 53 & IMD3002_LH_PL == 2460015 // *Change 2011
replace party_PID = 316 if countryelection_FE == 53 & PID_who == 2460015
replace type_voted = 7 if countryelection_FE == 53 & IMD3002_LH_PL == 2460015
replace type_PID = 7 if countryelection_FE == 53 & PID_who == 2460015

replace party_voted = 53 if countryelection_FE == 53 & IMD3002_LH_PL == 2460016 // *Pirate Party
replace party_PID = 53 if countryelection_FE == 53 & PID_who == 2460016
replace type_voted = 6 if countryelection_FE == 53 & IMD3002_LH_PL == 2460016
replace type_PID = 6 if countryelection_FE == 53 & PID_who == 2460016

replace party_voted = 57 if countryelection_FE == 53 & IMD3002_LH_PL == 2460021 // *Freedom Party - Blue and White Front
replace party_PID = 57 if countryelection_FE == 53 & PID_who == 2460021
replace type_voted = 7 if countryelection_FE == 53 & IMD3002_LH_PL == 2460021
replace type_PID = 7 if countryelection_FE == 53 & PID_who == 2460021

replace party_voted = 54 if countryelection_FE == 53 & IMD3002_LH_PL == 2460017 // *Finnish Senior Citizen's Party
replace party_PID = 54 if countryelection_FE == 53 & PID_who == 2460017
replace type_voted = 3 if countryelection_FE == 53 & IMD3002_LH_PL == 2460017
replace type_PID = 3 if countryelection_FE == 53 & PID_who == 2460017

replace party_voted = 55 if countryelection_FE == 53 & IMD3002_LH_PL == 2460018 // *Finnish Communist Party
replace party_PID = 55 if countryelection_FE == 53 & PID_who == 2460018
replace type_voted = 6 if countryelection_FE == 53 & IMD3002_LH_PL == 2460018
replace type_PID = 6 if countryelection_FE == 53 & PID_who == 2460018

replace party_voted = 56 if countryelection_FE == 53 & IMD3002_LH_PL == 2460020 // *Finnish Workers' Party
replace party_PID = 56 if countryelection_FE == 53 & PID_who == 2460020
replace type_voted = 6 if countryelection_FE == 53 & IMD3002_LH_PL == 2460020
replace type_PID = 6 if countryelection_FE == 53 & PID_who == 2460020

//* Finland 2015

replace incumbent_voted = 1 if countryelection_FE == 54 & inlist(IMD3002_LH_PL,2460003, 2460008, 2460002,2460007)  //* KOK-SPP-SDP-ChristDem
replace incumbent_PID = 1 if countryelection_FE == 54 & inlist(PID_who,2460003, 2460008, 2460002,2460007)

replace party_voted = 41 if countryelection_FE == 54 & IMD3002_LH_PL == 2460001 //* Centre Party (KESK)
replace party_PID = 41 if countryelection_FE == 54 & PID_who == 2460001
replace type_voted = 1 if countryelection_FE == 54 & IMD3002_LH_PL == 2460001
replace type_PID = 1 if countryelection_FE == 54 & PID_who == 2460001

replace party_voted = 42 if countryelection_FE == 54 & IMD3002_LH_PL == 2460002 //* SDP
replace party_PID = 42 if countryelection_FE == 54 & PID_who == 2460002
replace type_voted = 1 if countryelection_FE == 54 & IMD3002_LH_PL == 2460002
replace type_PID = 1 if countryelection_FE == 54 & PID_who == 2460002

replace party_voted = 43 if countryelection_FE == 54 & IMD3002_LH_PL == 2460003 //* KoK (National Coalition)
replace party_PID = 43 if countryelection_FE == 54 & PID_who == 2460003
replace type_voted = 1 if countryelection_FE == 54 & IMD3002_LH_PL == 2460003
replace type_PID = 1 if countryelection_FE == 54 & PID_who == 2460003

replace party_voted = 44 if countryelection_FE == 54 & IMD3002_LH_PL == 2460004 //* True Finns
replace party_PID = 44 if countryelection_FE == 54 & PID_who == 2460004
replace type_voted = 7 if countryelection_FE == 54 & IMD3002_LH_PL == 2460004
replace type_PID = 7 if countryelection_FE == 54 & PID_who == 2460004

replace party_voted = 45 if countryelection_FE == 54 & IMD3002_LH_PL == 2460005 //* Green League
replace party_PID = 45 if countryelection_FE == 54 & PID_who == 2460005
replace type_voted = 1 if countryelection_FE == 54 & IMD3002_LH_PL == 2460005
replace type_PID = 1 if countryelection_FE == 54 & PID_who == 2460005

replace party_voted = 46 if countryelection_FE == 54 & IMD3002_LH_PL == 2460006 //* Left Alliance
replace party_PID = 46 if countryelection_FE == 54 & PID_who == 2460006
replace type_voted = 4 if countryelection_FE == 54 & IMD3002_LH_PL == 2460006
replace type_PID = 4 if countryelection_FE == 54 & PID_who == 2460006

replace party_voted = 47 if countryelection_FE == 54 & IMD3002_LH_PL == 2460007 //* Christian Democrats
replace party_PID = 47 if countryelection_FE == 54 & PID_who == 2460007
replace type_voted = 1 if countryelection_FE == 54 & IMD3002_LH_PL == 2460007
replace type_PID = 1 if countryelection_FE == 54 & PID_who == 2460007

replace party_voted = 48 if countryelection_FE == 54 & IMD3002_LH_PL == 2460008 // *Swedish People's Party
replace party_PID = 48 if countryelection_FE == 54 & PID_who == 2460008
replace type_voted = 1 if countryelection_FE == 54 & IMD3002_LH_PL == 2460008
replace type_PID = 1 if countryelection_FE == 54 & PID_who == 2460008

replace party_voted = 49 if countryelection_FE == 54 & IMD3002_LH_PL == 2460009 // *Independence Party
replace party_PID = 49 if countryelection_FE == 54 & PID_who == 2460009
replace type_voted = 7 if countryelection_FE == 54 & IMD3002_LH_PL == 2460009
replace type_PID = 7 if countryelection_FE == 54 & PID_who == 2460009

replace party_voted = 50 if countryelection_FE == 54 & IMD3002_LH_PL == 2460013 // *For Peace and Socialism
replace party_PID = 50 if countryelection_FE == 54 & PID_who == 2460013
replace type_voted = 6 if countryelection_FE == 54 & IMD3002_LH_PL == 2460013
replace type_PID = 6 if countryelection_FE == 54 & PID_who == 2460013

replace party_voted = 51 if countryelection_FE == 54 & IMD3002_LH_PL == 2460014 // *Liberal People's Party
replace party_PID = 51 if countryelection_FE == 54 & PID_who == 2460014
replace type_voted = 1 if countryelection_FE == 54 & IMD3002_LH_PL == 2460014
replace type_PID = 1 if countryelection_FE == 54 & PID_who == 2460014

replace party_voted = 316 if countryelection_FE == 54 & IMD3002_LH_PL == 2460012 // *For the Poor
replace party_PID = 316 if countryelection_FE == 54 & PID_who == 2460012
replace type_voted = 2 if countryelection_FE == 54 & IMD3002_LH_PL == 2460012
replace type_PID = 2 if countryelection_FE == 54 & PID_who == 2460012

replace party_voted = 316 if countryelection_FE == 54 & IMD3002_LH_PL == 2460015 // *Change 2011
replace party_PID = 316 if countryelection_FE == 54 & PID_who == 2460015
replace type_voted = 7 if countryelection_FE == 54 & IMD3002_LH_PL == 2460015
replace type_PID = 7 if countryelection_FE == 54 & PID_who == 2460015

replace party_voted = 53 if countryelection_FE == 54 & IMD3002_LH_PL == 2460016 // *Pirate Party
replace party_PID = 53 if countryelection_FE == 54 & PID_who == 2460016
replace type_voted = 6 if countryelection_FE == 54 & IMD3002_LH_PL == 2460016
replace type_PID = 6 if countryelection_FE == 54 & PID_who == 2460016

replace party_voted = 57 if countryelection_FE == 54 & IMD3002_LH_PL == 2460021 // *Freedom Party - Blue and White Front
replace party_PID = 57 if countryelection_FE == 54 & PID_who == 2460021
replace type_voted = 7 if countryelection_FE == 54 & IMD3002_LH_PL == 2460021
replace type_PID = 7 if countryelection_FE == 54 & PID_who == 2460021

replace party_voted = 54 if countryelection_FE == 54 & IMD3002_LH_PL == 2460017 // *Finnish Senior Citizen's Party
replace party_PID = 54 if countryelection_FE == 54 & PID_who == 2460017
replace type_voted = 3 if countryelection_FE == 54 & IMD3002_LH_PL == 2460017
replace type_PID = 3 if countryelection_FE == 54 & PID_who == 2460017

replace party_voted = 55 if countryelection_FE == 54 & IMD3002_LH_PL == 2460018 // *Finnish Communist Party
replace party_PID = 55 if countryelection_FE == 54 & PID_who == 2460018
replace type_voted = 6 if countryelection_FE == 54 & IMD3002_LH_PL == 2460018
replace type_PID = 6 if countryelection_FE == 54 & PID_who == 2460018

replace party_voted = 56 if countryelection_FE == 54 & IMD3002_LH_PL == 2460020 // *Finnish Workers' Party
replace party_PID = 56 if countryelection_FE == 54 & PID_who == 2460020
replace type_voted = 6 if countryelection_FE == 54 & IMD3002_LH_PL == 2460020
replace type_PID = 6 if countryelection_FE == 54 & PID_who == 2460020





//* France 2007

replace incumbent_voted = 1 if countryelection_FE == 56 & inlist(IMD3002_LH_DC,2500001,2500018,2500020)  //* UMP, RadParty, NewCentre
replace incumbent_PID = 1 if countryelection_FE == 56 & inlist(PID_who,2500001,2500018,2500020)

replace party_voted = 246 if countryelection_FE == 56 & IMD3002_LH_DC == 2500001 //* UMP
replace party_PID = 246 if countryelection_FE == 56 & PID_who == 2500001
replace type_voted = 1 if countryelection_FE == 56 & IMD3002_LH_DC == 2500001
replace type_PID = 1 if countryelection_FE == 56 & PID_who == 2500001

replace party_voted = 247 if countryelection_FE == 56 & IMD3002_LH_DC == 2500002 //* Socialist Party
replace party_PID = 247 if countryelection_FE == 56 & PID_who == 2500002
replace type_voted = 1 if countryelection_FE == 56 & IMD3002_LH_DC == 2500002
replace type_PID = 1 if countryelection_FE == 56 & PID_who == 2500002

replace party_voted = 248 if countryelection_FE == 56 & IMD3002_LH_DC == 2500003 //* UDF/MODEM
replace party_PID = 248 if countryelection_FE == 56 & PID_who == 2500003
replace type_voted = 1 if countryelection_FE == 56 & IMD3002_LH_DC == 2500003
replace type_PID = 1 if countryelection_FE == 56 & PID_who == 2500003

replace party_voted = 249 if countryelection_FE == 56 & IMD3002_LH_DC == 2500004 //* French Communist Party
replace party_PID = 249 if countryelection_FE == 56 & PID_who == 2500004
replace type_voted = 6 if countryelection_FE == 56 & IMD3002_LH_DC == 2500004
replace type_PID = 6 if countryelection_FE == 56 & PID_who == 2500004

replace party_voted = 250 if countryelection_FE == 56 & IMD3002_LH_DC == 2500005 //* The Greens
replace party_PID = 250 if countryelection_FE == 56 & PID_who == 2500005
replace type_voted = 1 if countryelection_FE == 56 & IMD3002_LH_DC == 2500005
replace type_PID = 1 if countryelection_FE == 56 & PID_who == 2500005

replace party_voted = 251 if countryelection_FE == 56 & IMD3002_LH_DC == 2500007 //* National Front
replace party_PID = 251 if countryelection_FE == 56 & PID_who == 2500007
replace type_voted = 7 if countryelection_FE == 56 & IMD3002_LH_DC == 2500007
replace type_PID = 7 if countryelection_FE == 56 & PID_who == 2500007

replace party_voted = 252 if countryelection_FE == 56 & IMD3002_LH_DC == 2500010 //* Movement for France
replace party_PID = 252 if countryelection_FE == 56 & PID_who == 2500010
replace type_voted = 3 if countryelection_FE == 56 & IMD3002_LH_DC == 2500010
replace type_PID = 3 if countryelection_FE == 56 & PID_who == 2500010

replace party_voted = 253 if countryelection_FE == 56 & IMD3002_LH_DC == 2500011 //* Hunting, Fishing, Nature
replace party_PID = 253 if countryelection_FE == 56 & PID_who == 2500011
replace type_voted = 3 if countryelection_FE == 56 & IMD3002_LH_DC == 2500011
replace type_PID = 3 if countryelection_FE == 56 & PID_who == 2500011

replace party_voted = 254 if countryelection_FE == 56 & IMD3002_LH_DC == 2500018 //* Radical Party of the Left
replace party_PID = 254 if countryelection_FE == 56 & PID_who == 2500018
replace type_voted = 1 if countryelection_FE == 56 & IMD3002_LH_DC == 2500018
replace type_PID = 1 if countryelection_FE == 56 & PID_who == 2500018

replace party_voted = 256 if countryelection_FE == 56 & IMD3002_LH_DC == 2500020 //* New Centre
replace party_PID = 256 if countryelection_FE == 56 & PID_who == 2500020
replace type_voted = 1 if countryelection_FE == 56 & IMD3002_LH_DC == 2500020
replace type_PID = 1 if countryelection_FE == 56 & PID_who == 2500020

replace party_voted = 258 if countryelection_FE == 56 & IMD3002_LH_DC == 2500023 //* Regionalists
replace party_PID = 258 if countryelection_FE == 56 & PID_who == 2500023
replace type_voted = 2 if countryelection_FE == 56 & IMD3002_LH_DC == 2500023
replace type_PID = 2 if countryelection_FE == 56 & PID_who == 2500023

replace party_voted = 317 if countryelection_FE == 56 & IMD3002_LH_DC == 2500009 //* Workers' Struggle
replace party_PID = 317 if countryelection_FE == 56 & PID_who == 2500009
replace type_voted = 6 if countryelection_FE == 56 & IMD3002_LH_DC == 2500009
replace type_PID = 6 if countryelection_FE == 56 & PID_who == 2500009

replace party_voted = 318 if countryelection_FE == 56 & IMD3002_LH_DC == 2500014 //* Revolutionary Communists
replace party_PID = 318 if countryelection_FE == 56 & PID_who == 2500014
replace type_voted = 6 if countryelection_FE == 56 & IMD3002_LH_DC == 2500014
replace type_PID = 6 if countryelection_FE == 56 & PID_who == 2500014

//* Britain 1997

replace incumbent_voted = 1 if countryelection_FE == 58 & inlist(IMD3002_LH_DC,8260001)  //* Tories
replace incumbent_PID = 1 if countryelection_FE == 58 & inlist(PID_who,8260001)

replace party_voted = 299 if countryelection_FE == 58 & IMD3002_LH_DC == 8260001 //* Tories
replace party_PID = 299 if countryelection_FE == 58 & PID_who == 8260001
replace type_voted = 1 if countryelection_FE == 58 & IMD3002_LH_DC == 8260001
replace type_PID = 1 if countryelection_FE == 58 & PID_who == 8260001

replace party_voted = 300 if countryelection_FE == 58 & IMD3002_LH_DC == 8260002 //* Labour
replace party_PID = 300 if countryelection_FE == 58 & PID_who == 8260002
replace type_voted = 1 if countryelection_FE == 58 & IMD3002_LH_DC == 8260002
replace type_PID = 1 if countryelection_FE == 58 & PID_who == 8260002

replace party_voted = 301 if countryelection_FE == 58 & IMD3002_LH_DC == 8260003 //* Lib Dem
replace party_PID = 301 if countryelection_FE == 58 & PID_who == 8260003
replace type_voted = 1 if countryelection_FE == 58 & IMD3002_LH_DC == 8260003
replace type_PID = 1 if countryelection_FE == 58 & PID_who == 8260003

replace party_voted = 302 if countryelection_FE == 58 & IMD3002_LH_DC == 8260004 //* SNP
replace party_PID = 302 if countryelection_FE == 58 & PID_who == 8260004
replace type_voted = 6 if countryelection_FE == 58 & IMD3002_LH_DC == 8260004
replace type_PID = 6 if countryelection_FE == 58 & PID_who == 8260004

replace party_voted = 304 if countryelection_FE == 58 & IMD3002_LH_DC == 8260006 //* Plaid Cymru
replace party_PID = 304 if countryelection_FE == 58 & PID_who == 8260006
replace type_voted = 6 if countryelection_FE == 58 & IMD3002_LH_DC == 8260006
replace type_PID = 6 if countryelection_FE == 58 & PID_who == 8260006


//* Britain 2005

replace incumbent_voted = 1 if countryelection_FE == 59 & inlist(IMD3002_LH_DC,8260002)  //* Labour
replace incumbent_PID = 1 if countryelection_FE == 59 & inlist(PID_who,8260002)

replace party_voted = 299 if countryelection_FE == 59 & IMD3002_LH_DC == 8260001 //* Tories
replace party_PID = 299 if countryelection_FE == 59 & PID_who == 8260001
replace type_voted = 1 if countryelection_FE == 59 & IMD3002_LH_DC == 8260001
replace type_PID = 1 if countryelection_FE == 59 & PID_who == 8260001

replace party_voted = 300 if countryelection_FE == 59 & IMD3002_LH_DC == 8260002 //* Labour
replace party_PID = 300 if countryelection_FE == 59 & PID_who == 8260002
replace type_voted = 1 if countryelection_FE == 59 & IMD3002_LH_DC == 8260002
replace type_PID = 1 if countryelection_FE == 59 & PID_who == 8260002

replace party_voted = 301 if countryelection_FE == 59 & IMD3002_LH_DC == 8260003 //* Lib Dem
replace party_PID = 301 if countryelection_FE == 59 & PID_who == 8260003
replace type_voted = 1 if countryelection_FE == 59 & IMD3002_LH_DC == 8260003
replace type_PID = 1 if countryelection_FE == 59 & PID_who == 8260003

replace party_voted = 302 if countryelection_FE == 59 & IMD3002_LH_DC == 8260004 //* SNP
replace party_PID = 302 if countryelection_FE == 59 & PID_who == 8260004
replace type_voted = 6 if countryelection_FE == 59 & IMD3002_LH_DC == 8260004
replace type_PID = 6 if countryelection_FE == 59 & PID_who == 8260004

replace party_voted = 304 if countryelection_FE == 59 & IMD3002_LH_DC == 8260006 //* Plaid Cymru
replace party_PID = 304 if countryelection_FE == 59 & PID_who == 8260006
replace type_voted = 6 if countryelection_FE == 59 & IMD3002_LH_DC == 8260006
replace type_PID = 6 if countryelection_FE == 59 & PID_who == 8260006

//* Britain 2015

replace incumbent_voted = 1 if countryelection_FE == 60 & inlist(IMD3002_LH_DC,8260001,8260003)  //* Tories and LibDem
replace incumbent_PID = 1 if countryelection_FE == 60 & inlist(PID_who,8260001,8260003)

replace party_voted = 299 if countryelection_FE == 60 & IMD3002_LH_DC == 8260001 //* Tories
replace party_PID = 299 if countryelection_FE == 60 & PID_who == 8260001
replace type_voted = 1 if countryelection_FE == 60 & IMD3002_LH_DC == 8260001
replace type_PID = 1 if countryelection_FE == 60 & PID_who == 8260001

replace party_voted = 300 if countryelection_FE == 60 & IMD3002_LH_DC == 8260002 //* Labour
replace party_PID = 300 if countryelection_FE == 60 & PID_who == 8260002
replace type_voted = 1 if countryelection_FE == 60 & IMD3002_LH_DC == 8260002
replace type_PID = 1 if countryelection_FE == 60 & PID_who == 8260002

replace party_voted = 301 if countryelection_FE == 60 & IMD3002_LH_DC == 8260003 //* Lib Dem
replace party_PID = 301 if countryelection_FE == 60 & PID_who == 8260003
replace type_voted = 1 if countryelection_FE == 60 & IMD3002_LH_DC == 8260003
replace type_PID = 1 if countryelection_FE == 60 & PID_who == 8260003

replace party_voted = 302 if countryelection_FE == 60 & IMD3002_LH_DC == 8260004 //* SNP
replace party_PID = 302 if countryelection_FE == 60 & PID_who == 8260004
replace type_voted = 6 if countryelection_FE == 60 & IMD3002_LH_DC == 8260004
replace type_PID = 6 if countryelection_FE == 60 & PID_who == 8260004

replace party_voted = 304 if countryelection_FE == 60 & IMD3002_LH_DC == 8260006 //* Plaid Cymru
replace party_PID = 304 if countryelection_FE == 60 & PID_who == 8260006
replace type_voted = 6 if countryelection_FE == 60 & IMD3002_LH_DC == 8260006
replace type_PID = 6 if countryelection_FE == 60 & PID_who == 8260006

replace party_voted = 303 if countryelection_FE == 60 & IMD3002_LH_DC == 8260005 //* Greens
replace party_PID = 303 if countryelection_FE == 60 & PID_who ==  8260005
replace type_voted = 6 if countryelection_FE == 60 & IMD3002_LH_DC == 8260005
replace type_PID = 6 if countryelection_FE == 60 & PID_who == 8260005

replace party_voted = 346 if countryelection_FE == 60 & IMD3002_LH_DC == 8260007 //* UKIP
replace party_PID = 346 if countryelection_FE == 60 & PID_who ==  8260007
replace type_voted = 7 if countryelection_FE == 60 & IMD3002_LH_DC == 8260007
replace type_PID = 7 if countryelection_FE == 60 & PID_who == 8260007



//* Greece 2009

replace incumbent_voted = 1 if countryelection_FE == 61 & inlist(IMD3002_LH_PL,3000002)  //* New Democracy
replace incumbent_PID = 1 if countryelection_FE == 61 & inlist(PID_who,3000002)

replace party_voted = 83 if countryelection_FE == 61 & IMD3002_LH_PL == 3000001 //* PASOK
replace party_PID = 83 if countryelection_FE == 61 & PID_who == 3000001
replace type_voted = 1 if countryelection_FE == 61 & IMD3002_LH_PL == 3000001
replace type_PID = 1 if countryelection_FE == 61 & PID_who == 3000001

replace party_voted = 84 if countryelection_FE == 61 & IMD3002_LH_PL == 3000002 //* New Democracy
replace party_PID = 84 if countryelection_FE == 61 & PID_who == 3000002
replace type_voted = 1 if countryelection_FE == 61 & IMD3002_LH_PL == 3000002
replace type_PID = 1 if countryelection_FE == 61 & PID_who == 3000002

replace party_voted = 85 if countryelection_FE == 61 & IMD3002_LH_PL == 3000003 //* SYRIZA
replace party_PID = 85 if countryelection_FE == 61 & PID_who == 3000003
replace type_voted = 6 if countryelection_FE == 61 & IMD3002_LH_PL == 3000003
replace type_PID = 6 if countryelection_FE == 61 & PID_who == 3000003

replace party_voted = 86 if countryelection_FE == 61 & IMD3002_LH_PL == 3000004 //* KKE
replace party_PID = 86 if countryelection_FE == 61 & PID_who == 3000004
replace type_voted = 6 if countryelection_FE == 61 & IMD3002_LH_PL == 3000004
replace type_PID = 6 if countryelection_FE == 61 & PID_who == 3000004

replace party_voted = 87 if countryelection_FE == 61 & IMD3002_LH_PL == 3000005 //* Greek Ecologist Greens
replace party_PID = 87 if countryelection_FE == 61 & PID_who == 3000005
replace type_voted = 6 if countryelection_FE == 61 & IMD3002_LH_PL == 3000005
replace type_PID = 6 if countryelection_FE == 61 & PID_who == 3000005

replace party_voted = 92 if countryelection_FE == 61 & IMD3002_LH_PL == 3000019 //* Popular Orthodox Rally
replace party_PID = 92 if countryelection_FE == 61 & PID_who == 3000019
replace type_voted = 7 if countryelection_FE == 61 & IMD3002_LH_PL == 3000019
replace type_PID = 7 if countryelection_FE == 61 & PID_who == 3000019



//* Greece 2012

replace incumbent_voted = 1 if countryelection_FE == 62 & inlist(IMD3002_LH_PL,3000001,3000002)  //* PASOK - New Democracy
replace incumbent_PID = 1 if countryelection_FE == 62 & inlist(PID_who,3000001,3000002)

replace party_voted = 83 if countryelection_FE == 62 & IMD3002_LH_PL == 3000001 //* PASOK
replace party_PID = 83 if countryelection_FE == 62 & PID_who == 3000001
replace type_voted = 1 if countryelection_FE == 62 & IMD3002_LH_PL == 3000001
replace type_PID = 1 if countryelection_FE == 62 & PID_who == 3000001

replace party_voted = 84 if countryelection_FE == 62 & IMD3002_LH_PL == 3000002 //* New Democracy
replace party_PID = 84 if countryelection_FE == 62 & PID_who == 3000002
replace type_voted = 1 if countryelection_FE == 62 & IMD3002_LH_PL == 3000002
replace type_PID = 1 if countryelection_FE == 62 & PID_who == 3000002

replace party_voted = 85 if countryelection_FE == 62 & IMD3002_LH_PL == 3000003 //* SYRIZA
replace party_PID = 85 if countryelection_FE == 62 & PID_who == 3000003
replace type_voted = 6 if countryelection_FE == 62 & IMD3002_LH_PL == 3000003
replace type_PID = 6 if countryelection_FE == 62 & PID_who == 3000003

replace party_voted = 86 if countryelection_FE == 62 & IMD3002_LH_PL == 3000004 //* KKE
replace party_PID = 86 if countryelection_FE == 62 & PID_who == 3000004
replace type_voted = 6 if countryelection_FE == 62 & IMD3002_LH_PL == 3000004
replace type_PID = 6 if countryelection_FE == 62 & PID_who == 3000004

replace party_voted = 87 if countryelection_FE == 62 & IMD3002_LH_PL == 3000005 //* Greek Ecologist Greens
replace party_PID = 87 if countryelection_FE == 62 & PID_who == 3000005
replace type_voted = 6 if countryelection_FE == 62 & IMD3002_LH_PL == 3000005
replace type_PID = 6 if countryelection_FE == 62 & PID_who == 3000005

replace party_voted = 88 if countryelection_FE == 62 & IMD3002_LH_PL == 3000006 //* Golden Dawn
replace party_PID = 88 if countryelection_FE == 62 & PID_who == 3000006
replace type_voted = 7 if countryelection_FE == 62 & IMD3002_LH_PL == 3000006
replace type_PID = 7 if countryelection_FE == 62 & PID_who == 3000006

replace party_voted = 89 if countryelection_FE == 62 & IMD3002_LH_PL == 3000007 //* Independent Greeks
replace party_PID = 89 if countryelection_FE == 62 & PID_who == 3000007
replace type_voted = 7 if countryelection_FE == 62 & IMD3002_LH_PL == 3000007
replace type_PID = 7 if countryelection_FE == 62 & PID_who == 3000007

replace party_voted = 90 if countryelection_FE == 62 & IMD3002_LH_PL == 3000012 //* Democratic Left
replace party_PID = 90 if countryelection_FE == 62 & PID_who == 3000012
replace type_voted = 2 if countryelection_FE == 62 & IMD3002_LH_PL == 3000012
replace type_PID = 2 if countryelection_FE == 62 & PID_who == 3000012

replace party_voted = 92 if countryelection_FE == 62 & IMD3002_LH_PL == 3000019 //* Popular Orthodox Rally
replace party_PID = 92 if countryelection_FE == 62 & PID_who == 3000019
replace type_voted = 5 if countryelection_FE == 62 & IMD3002_LH_PL == 3000019
replace type_PID = 5 if countryelection_FE == 62 & PID_who == 3000019

replace party_voted = 320 if countryelection_FE == 62 & IMD3002_LH_PL == 3000010 //* Pirate Party
replace party_PID = 320 if countryelection_FE == 62 & PID_who == 3000010
replace type_voted = 6 if countryelection_FE == 62 & IMD3002_LH_PL == 3000010
replace type_PID = 6 if countryelection_FE == 62 & PID_who == 3000010

replace party_voted = 305 if countryelection_FE == 62 & IMD3002_LH_PL == 3000011 //* Recreate Greece
replace party_PID = 305 if countryelection_FE == 62 & PID_who == 3000011
replace type_voted = 3 if countryelection_FE == 62 & IMD3002_LH_PL == 3000011
replace type_PID = 3 if countryelection_FE == 62 & PID_who == 3000011

replace party_voted = 306 if countryelection_FE == 62 & IMD3002_LH_PL == 3000016 //* Anticapitalist Left 
replace party_PID = 306 if countryelection_FE == 62 & PID_who == 3000016
replace type_voted = 7 if countryelection_FE == 62 & IMD3002_LH_PL == 3000016
replace type_PID = 7 if countryelection_FE == 62 & PID_who == 3000016

replace party_voted = 307 if countryelection_FE == 62 & IMD3002_LH_PL == 3000017 //* Action Greece
replace party_PID = 307 if countryelection_FE == 62 & PID_who == 3000017
replace type_voted = 3 if countryelection_FE == 62 & IMD3002_LH_PL == 3000017
replace type_PID = 3 if countryelection_FE == 62 & PID_who == 3000017

replace party_voted = 347 if countryelection_FE == 62 & IMD3002_LH_PL == 3000018 //* Democratic Revival
replace party_PID = 347 if countryelection_FE == 62 & PID_who == 3000018
replace type_voted = 3 if countryelection_FE == 62 & IMD3002_LH_PL == 3000018
replace type_PID = 3 if countryelection_FE == 62 & PID_who == 3000018


//* Greece 2015

replace incumbent_voted = 1 if countryelection_FE == 63 & inlist(IMD3002_LH_PL,3000001,3000002)  //* PASOK - New Democracy
replace incumbent_PID = 1 if countryelection_FE == 63 & inlist(PID_who,3000001,3000002)

replace party_voted = 83 if countryelection_FE == 63 & IMD3002_LH_PL == 3000001 //* PASOK
replace party_PID = 83 if countryelection_FE == 63 & PID_who == 3000001
replace type_voted = 1 if countryelection_FE == 63 & IMD3002_LH_PL == 3000001
replace type_PID = 1 if countryelection_FE == 63 & PID_who == 3000001

replace party_voted = 84 if countryelection_FE == 63 & IMD3002_LH_PL == 3000002 //* New Democracy
replace party_PID = 84 if countryelection_FE == 63 & PID_who == 3000002
replace type_voted = 1 if countryelection_FE == 63 & IMD3002_LH_PL == 3000002
replace type_PID = 1 if countryelection_FE == 63 & PID_who == 3000002

replace party_voted = 85 if countryelection_FE == 63 & IMD3002_LH_PL == 3000003 //* SYRIZA
replace party_PID = 85 if countryelection_FE == 63 & PID_who == 3000003
replace type_voted = 6 if countryelection_FE == 63 & IMD3002_LH_PL == 3000003
replace type_PID = 6 if countryelection_FE == 63 & PID_who == 3000003

replace party_voted = 86 if countryelection_FE == 63 & IMD3002_LH_PL == 3000004 //* KKE
replace party_PID = 86 if countryelection_FE == 63 & PID_who == 3000004
replace type_voted = 6 if countryelection_FE == 63 & IMD3002_LH_PL == 3000004
replace type_PID = 6 if countryelection_FE == 63 & PID_who == 3000004

replace party_voted = 87 if countryelection_FE == 63 & IMD3002_LH_PL == 3000005 //* Greek Ecologist Greens
replace party_PID = 87 if countryelection_FE == 63 & PID_who == 3000005
replace type_voted = 6 if countryelection_FE == 63 & IMD3002_LH_PL == 3000005
replace type_PID = 6 if countryelection_FE == 63 & PID_who == 3000005

replace party_voted = 88 if countryelection_FE == 63 & IMD3002_LH_PL == 3000006 //* Golden Dawn
replace party_PID = 88 if countryelection_FE == 63 & PID_who == 3000006
replace type_voted = 7 if countryelection_FE == 63 & IMD3002_LH_PL == 3000006
replace type_PID = 7 if countryelection_FE == 63 & PID_who == 3000006

replace party_voted = 89 if countryelection_FE == 63 & IMD3002_LH_PL == 3000007 //* Independent Greeks
replace party_PID = 89 if countryelection_FE == 63 & PID_who == 3000007
replace type_voted = 7 if countryelection_FE == 63 & IMD3002_LH_PL == 3000007
replace type_PID = 7 if countryelection_FE == 63 & PID_who == 3000007

replace party_voted = 90 if countryelection_FE == 63 & IMD3002_LH_PL == 3000012 //* Democratic Left
replace party_PID = 90 if countryelection_FE == 63 & PID_who == 3000012
replace type_voted = 1 if countryelection_FE == 63 & IMD3002_LH_PL == 3000012
replace type_PID = 1 if countryelection_FE == 63 & PID_who == 3000012

replace party_voted = 92 if countryelection_FE == 63 & IMD3002_LH_PL == 3000019 //* Popular Orthodox Rally
replace party_PID = 92 if countryelection_FE == 63 & PID_who == 3000019
replace type_voted = 5 if countryelection_FE == 63 & IMD3002_LH_PL == 3000019
replace type_PID = 5 if countryelection_FE == 63 & PID_who == 3000019

replace party_voted = 320 if countryelection_FE == 63 & IMD3002_LH_PL == 3000010 //* Pirate Party
replace party_PID = 320 if countryelection_FE == 63 & PID_who == 3000010
replace type_voted = 6 if countryelection_FE == 63 & IMD3002_LH_PL == 3000010
replace type_PID = 6 if countryelection_FE == 63 & PID_who == 3000010

replace party_voted = 305 if countryelection_FE == 63 & IMD3002_LH_PL == 3000011 //* Recreate Greece
replace party_PID = 305 if countryelection_FE == 63 & PID_who == 3000011
replace type_voted = 3 if countryelection_FE == 63 & IMD3002_LH_PL == 3000011
replace type_PID = 3 if countryelection_FE == 63 & PID_who == 3000011

replace party_voted = 306 if countryelection_FE == 63 & IMD3002_LH_PL == 3000016 //* Anticapitalist Left 
replace party_PID = 306 if countryelection_FE == 63 & PID_who == 3000016
replace type_voted = 6 if countryelection_FE == 63 & IMD3002_LH_PL == 3000016
replace type_PID = 6 if countryelection_FE == 63 & PID_who == 3000016

replace party_voted = 307 if countryelection_FE == 63 & IMD3002_LH_PL == 3000017 //* Action Greece
replace party_PID = 307 if countryelection_FE == 63 & PID_who == 3000017
replace type_voted = 3 if countryelection_FE == 63 & IMD3002_LH_PL == 3000017
replace type_PID = 3 if countryelection_FE == 63 & PID_who == 3000017

replace party_voted = 347 if countryelection_FE == 63 & IMD3002_LH_PL == 3000018 //* Democratic Revival
replace party_PID = 347 if countryelection_FE == 63 & PID_who == 3000018
replace type_voted = 3 if countryelection_FE == 63 & IMD3002_LH_PL == 3000018
replace type_PID = 3 if countryelection_FE == 63 & PID_who == 3000018

replace party_voted = 91 if countryelection_FE == 63 & IMD3002_LH_PL == 3000013 //* The River
replace party_PID = 91 if countryelection_FE == 63 & PID_who == 3000013
replace type_voted = 2 if countryelection_FE == 63 & IMD3002_LH_PL == 3000013
replace type_PID = 2 if countryelection_FE == 63 & PID_who == 3000013

replace party_voted = 308 if countryelection_FE == 63 & IMD3002_LH_PL == 3000021 //* Union of Centrists
replace party_PID = 308 if countryelection_FE == 63 & PID_who == 3000021
replace type_voted = 3 if countryelection_FE == 63 & IMD3002_LH_PL == 3000021
replace type_PID = 3 if countryelection_FE == 63 & PID_who == 3000021

replace party_voted = 309 if countryelection_FE == 63 & IMD3002_LH_PL == 3000022 //* Movement of Democratic Socialists
replace party_PID = 309 if countryelection_FE == 63 & PID_who == 3000022
replace type_voted = 2 if countryelection_FE == 63 & IMD3002_LH_PL == 3000022
replace type_PID = 2 if countryelection_FE == 63 & PID_who == 3000022


//* Ireland 2002

replace incumbent_voted = 1 if countryelection_FE == 72 & inlist(IMD3002_LH_DC,3720001,3720006)  //* Fianna Fial - Prog-Dem
replace incumbent_PID = 1 if countryelection_FE == 72 & inlist(PID_who,3720001,3720006)

replace party_voted = 259 if countryelection_FE == 72 & IMD3002_LH_DC == 3720001 //* Fianna Fail
replace party_PID = 259 if countryelection_FE == 72 & PID_who == 3720001
replace type_voted = 1 if countryelection_FE == 72 & IMD3002_LH_DC == 3720001
replace type_PID = 1 if countryelection_FE == 72 & PID_who == 3720001

replace party_voted = 260 if countryelection_FE == 72 & IMD3002_LH_DC == 3720002 //* Fine Gael
replace party_PID = 260 if countryelection_FE == 72 & PID_who == 3720002
replace type_voted = 1 if countryelection_FE == 72 & IMD3002_LH_DC == 3720002
replace type_PID = 1 if countryelection_FE == 72 & PID_who == 3720002

replace party_voted = 261 if countryelection_FE == 72 & IMD3002_LH_DC == 3720003 //* Labour
replace party_PID = 261 if countryelection_FE == 72 & PID_who == 3720003
replace type_voted = 1 if countryelection_FE == 72 & IMD3002_LH_DC == 3720003
replace type_PID = 1 if countryelection_FE == 72 & PID_who == 3720003

replace party_voted = 262 if countryelection_FE == 72 & IMD3002_LH_DC == 3720004 //* Sinn Fein
replace party_PID = 262 if countryelection_FE == 72 & PID_who == 3720004
replace type_voted = 6 if countryelection_FE == 72 & IMD3002_LH_DC == 3720004
replace type_PID = 6 if countryelection_FE == 72 & PID_who == 3720004

replace party_voted = 263 if countryelection_FE == 72 & IMD3002_LH_DC == 3720005 //* Green Party
replace party_PID = 263 if countryelection_FE == 72 & PID_who == 3720005
replace type_voted = 6 if countryelection_FE == 72 & IMD3002_LH_DC == 3720005
replace type_PID = 6 if countryelection_FE == 72 & PID_who == 3720005

replace party_voted = 264 if countryelection_FE == 72 & IMD3002_LH_DC == 3720006 //* Progressive Democrats
replace party_PID = 264 if countryelection_FE == 72 & PID_who == 3720006
replace type_voted = 1 if countryelection_FE == 72 & IMD3002_LH_DC == 3720006
replace type_PID = 1 if countryelection_FE == 72 & PID_who == 3720006


//* Ireland 2007

replace incumbent_voted = 1 if countryelection_FE == 73 & inlist(IMD3002_LH_DC,3720001,3720006)  //* Fianna Fial - Prog-Dem
replace incumbent_PID = 1 if countryelection_FE == 73 & inlist(PID_who,3720001,3720006)

replace party_voted = 259 if countryelection_FE == 73 & IMD3002_LH_DC == 3720001 //* Fianna Fail
replace party_PID = 259 if countryelection_FE == 73 & PID_who == 3720001
replace type_voted = 1 if countryelection_FE == 73 & IMD3002_LH_DC == 3720001
replace type_PID = 1 if countryelection_FE == 73 & PID_who == 3720001

replace party_voted = 260 if countryelection_FE == 73 & IMD3002_LH_DC == 3720002 //* Fine Gael
replace party_PID = 260 if countryelection_FE == 73 & PID_who == 3720002
replace type_voted = 1 if countryelection_FE == 73 & IMD3002_LH_DC == 3720002
replace type_PID = 1 if countryelection_FE == 73 & PID_who == 3720002

replace party_voted = 261 if countryelection_FE == 73 & IMD3002_LH_DC == 3720003 //* Labour
replace party_PID = 261 if countryelection_FE == 73 & PID_who == 3720003
replace type_voted = 1 if countryelection_FE == 73 & IMD3002_LH_DC == 3720003
replace type_PID = 1 if countryelection_FE == 73 & PID_who == 3720003

replace party_voted = 262 if countryelection_FE == 73 & IMD3002_LH_DC == 3720004 //* Sinn Fein
replace party_PID = 262 if countryelection_FE == 73 & PID_who == 3720004
replace type_voted = 6 if countryelection_FE == 73 & IMD3002_LH_DC == 3720004
replace type_PID = 6 if countryelection_FE == 73 & PID_who == 3720004

replace party_voted = 263 if countryelection_FE == 73 & IMD3002_LH_DC == 3720005 //* Green Party
replace party_PID = 263 if countryelection_FE == 73 & PID_who == 3720005
replace type_voted = 2 if countryelection_FE == 73 & IMD3002_LH_DC == 3720005
replace type_PID = 2 if countryelection_FE == 73 & PID_who == 3720005

replace party_voted = 264 if countryelection_FE == 73 & IMD3002_LH_DC == 3720006 //* Progressive Democrats
replace party_PID = 264 if countryelection_FE == 73 & PID_who == 3720006
replace type_voted = 1 if countryelection_FE == 73 & IMD3002_LH_DC == 3720006
replace type_PID = 1 if countryelection_FE == 73 & PID_who == 3720006

replace party_voted = 265 if countryelection_FE == 73 & IMD3002_LH_DC == 3720007 //* Socialist Party
replace party_PID = 265 if countryelection_FE == 73 & PID_who == 3720007
replace type_voted = 6 if countryelection_FE == 73 & IMD3002_LH_DC == 3720007
replace type_PID = 6 if countryelection_FE == 73 & PID_who == 3720007

replace party_voted = 266 if countryelection_FE == 73 & IMD3002_LH_DC == 3720008 //* Workers' Party
replace party_PID = 266 if countryelection_FE == 73 & PID_who == 3720008
replace type_voted = 6 if countryelection_FE == 73 & IMD3002_LH_DC == 3720008
replace type_PID = 6 if countryelection_FE == 73 & PID_who == 3720008

replace party_voted = 267 if countryelection_FE == 73 & IMD3002_LH_DC == 3720010 //* People before Profit
replace party_PID = 267 if countryelection_FE == 73 & PID_who == 3720010
replace type_voted = 6 if countryelection_FE == 73 & IMD3002_LH_DC == 3720010
replace type_PID = 6 if countryelection_FE == 73 & PID_who == 3720010

replace party_voted = 268 if countryelection_FE == 73 & IMD3002_LH_DC == 3720021 //* Father's Rights
replace party_PID = 268 if countryelection_FE == 73 & PID_who == 3720021
replace type_voted = 3 if countryelection_FE == 73 & IMD3002_LH_DC == 3720021
replace type_PID = 3 if countryelection_FE == 73 & PID_who == 3720021

//* Ireland 2011

replace incumbent_voted = 1 if countryelection_FE == 74 & inlist(IMD3002_LH_DC,3720001,3720006,3720005)  //* Fianna Fial - Prog-Dem - Greens
replace incumbent_PID = 1 if countryelection_FE == 74 & inlist(PID_who,3720001,3720006,3720005)

replace party_voted = 259 if countryelection_FE == 74 & IMD3002_LH_DC == 3720001 //* Fianna Fail
replace party_PID = 259 if countryelection_FE == 74 & PID_who == 3720001
replace type_voted = 1 if countryelection_FE == 74 & IMD3002_LH_DC == 3720001
replace type_PID = 1 if countryelection_FE == 74 & PID_who == 3720001

replace party_voted = 260 if countryelection_FE == 74 & IMD3002_LH_DC == 3720002 //* Fine Gael
replace party_PID = 260 if countryelection_FE == 74 & PID_who == 3720002
replace type_voted = 1 if countryelection_FE == 74 & IMD3002_LH_DC == 3720002
replace type_PID = 1 if countryelection_FE == 74 & PID_who == 3720002

replace party_voted = 261 if countryelection_FE == 74 & IMD3002_LH_DC == 3720003 //* Labour
replace party_PID = 261 if countryelection_FE == 74 & PID_who == 3720003
replace type_voted = 1 if countryelection_FE == 74 & IMD3002_LH_DC == 3720003
replace type_PID = 1 if countryelection_FE == 74 & PID_who == 3720003

replace party_voted = 262 if countryelection_FE == 74 & IMD3002_LH_DC == 3720004 //* Sinn Fein
replace party_PID = 262 if countryelection_FE == 74 & PID_who == 3720004
replace type_voted = 6 if countryelection_FE == 74 & IMD3002_LH_DC == 3720004
replace type_PID = 6 if countryelection_FE == 74 & PID_who == 3720004

replace party_voted = 263 if countryelection_FE == 74 & IMD3002_LH_DC == 3720005 //* Green Party
replace party_PID = 263 if countryelection_FE == 74 & PID_who == 3720005
replace type_voted = 1 if countryelection_FE == 74 & IMD3002_LH_DC == 3720005
replace type_PID = 1 if countryelection_FE == 74 & PID_who == 3720005

replace party_voted = 264 if countryelection_FE == 74 & IMD3002_LH_DC == 3720006 //* Progressive Democrats
replace party_PID = 264 if countryelection_FE == 74 & PID_who == 3720006
replace type_voted = 1 if countryelection_FE == 74 & IMD3002_LH_DC == 3720006
replace type_PID = 1 if countryelection_FE == 74 & PID_who == 3720006

replace party_voted = 265 if countryelection_FE == 74 & IMD3002_LH_DC == 3720007 //* Socialist Party
replace party_PID = 265 if countryelection_FE == 74 & PID_who == 3720007
replace type_voted = 6 if countryelection_FE == 74 & IMD3002_LH_DC == 3720007
replace type_PID = 6 if countryelection_FE == 74 & PID_who == 3720007

replace party_voted = 266 if countryelection_FE == 74 & IMD3002_LH_DC == 3720008 //* Workers' Party
replace party_PID = 266 if countryelection_FE == 74 & PID_who == 3720008
replace type_voted = 6 if countryelection_FE == 74 & IMD3002_LH_DC == 3720008
replace type_PID = 6 if countryelection_FE == 74 & PID_who == 3720008

replace party_voted = 267 if countryelection_FE == 74 & IMD3002_LH_DC == 3720010 //* People before Profit
replace party_PID = 267 if countryelection_FE == 74 & PID_who == 3720010
replace type_voted = 6 if countryelection_FE == 74 & IMD3002_LH_DC == 3720010
replace type_PID = 6 if countryelection_FE == 74 & PID_who == 3720010

replace party_voted = 268 if countryelection_FE == 74 & IMD3002_LH_DC == 3720021 //* Father's Rights
replace party_PID = 268 if countryelection_FE == 74 & PID_who == 3720021
replace type_voted = 3 if countryelection_FE == 74 & IMD3002_LH_DC == 3720021
replace type_PID = 3 if countryelection_FE == 74 & PID_who == 3720021

//* Iceland 1999

replace incumbent_voted = 1 if countryelection_FE == 75 & inlist(IMD3002_LH_PL,3520001,3520003)  //* Independence - Progressive
replace incumbent_PID = 1 if countryelection_FE == 75 & inlist(PID_who,3520001,3520003)

replace party_voted = 93 if countryelection_FE == 75 & IMD3002_LH_PL == 3520001 //* Independence Party
replace party_PID = 93 if countryelection_FE == 75 & PID_who == 3520001
replace type_voted = 1 if countryelection_FE == 75 & IMD3002_LH_PL == 3520001
replace type_PID = 1 if countryelection_FE == 75 & PID_who == 3520001

replace party_voted = 94 if countryelection_FE == 75 & IMD3002_LH_PL == 3520002 | countryelection_FE == 75 & IMD3002_LH_PL == 3520019 //* SocDem Alliance
replace party_PID = 94 if countryelection_FE == 75 & PID_who == 3520002 | countryelection_FE == 75 & PID_who == 3520019
replace type_voted = 1 if countryelection_FE == 75 & IMD3002_LH_PL == 3520002 | countryelection_FE == 75 & IMD3002_LH_PL == 3520019
replace type_PID = 1 if countryelection_FE == 75 & PID_who == 3520002 | countryelection_FE == 75 & PID_who == 3520019

replace party_voted = 95 if countryelection_FE == 75 & IMD3002_LH_PL == 3520003 //* Progressive Alliance
replace party_PID = 95 if countryelection_FE == 75 & PID_who == 3520003
replace type_voted = 1 if countryelection_FE == 75 & IMD3002_LH_PL == 3520003
replace type_PID = 1 if countryelection_FE == 75 & PID_who == 3520003

replace party_voted = 96 if countryelection_FE == 75 & IMD3002_LH_PL == 3520004 //* Liberal Party
replace party_PID = 96 if countryelection_FE == 75 & PID_who == 3520004
replace type_voted = 3 if countryelection_FE == 75 & IMD3002_LH_PL == 3520004
replace type_PID = 3 if countryelection_FE == 75 & PID_who == 3520004

replace party_voted = 97 if countryelection_FE == 75 & IMD3002_LH_PL == 3520005 //* Left-Green Alliance
replace party_PID = 97 if countryelection_FE == 75 & PID_who == 3520005
replace type_voted = 6 if countryelection_FE == 75 & IMD3002_LH_PL == 3520005
replace type_PID = 6 if countryelection_FE == 75 & PID_who == 3520005

replace party_voted = 108 if countryelection_FE == 75 & IMD3002_LH_PL == 3520022 //* Humanist Party
replace party_PID = 108 if countryelection_FE == 75 & PID_who == 3520022
replace type_voted = 2 if countryelection_FE == 75 & IMD3002_LH_PL == 3520022
replace type_PID = 2 if countryelection_FE == 75 & PID_who == 3520022

replace party_voted = 110 if countryelection_FE == 75 & IMD3002_LH_PL == 3520026 //* Christian Democrats
replace party_PID = 110 if countryelection_FE == 75 & PID_who == 3520026
replace type_voted = 3 if countryelection_FE == 75 & IMD3002_LH_PL == 3520026
replace type_PID = 3 if countryelection_FE == 75 & PID_who == 3520026

replace party_voted = 111 if countryelection_FE == 75 & IMD3002_LH_PL == 3520027 //* Anarchists
replace party_PID = 111 if countryelection_FE == 75 & PID_who == 3520027
replace type_voted = 6 if countryelection_FE == 75 & IMD3002_LH_PL == 3520027
replace type_PID = 6 if countryelection_FE == 75 & PID_who == 3520027

replace party_voted = 348 if countryelection_FE == 75 & IMD3002_LH_PL == 3520017 //* Citizen's Movement
replace party_PID = 348 if countryelection_FE == 75 & PID_who == 3520017
replace type_voted = 7 if countryelection_FE == 75 & IMD3002_LH_PL == 3520017
replace type_PID = 7 if countryelection_FE == 75 & PID_who == 3520017

replace party_voted = 311 if countryelection_FE == 75 & IMD3002_LH_PL == 3520020 //* People's Alliance
replace party_PID = 311 if countryelection_FE == 75 & PID_who == 3520020
replace type_voted = 4 if countryelection_FE == 75 & IMD3002_LH_PL == 3520020
replace type_PID = 4 if countryelection_FE == 75 & PID_who == 3520020

replace party_voted = 349 if countryelection_FE == 75 & IMD3002_LH_PL == 3520024 //* Women's Alliance
replace party_PID = 349 if countryelection_FE == 75 & PID_who == 3520024
replace type_voted = 6 if countryelection_FE == 75 & IMD3002_LH_PL == 3520024
replace type_PID = 6 if countryelection_FE == 75 & PID_who == 3520024

replace party_voted = 100 if countryelection_FE == 75 & IMD3002_LH_PL == 3520009 //* Civic Movement
replace party_PID = 100 if countryelection_FE == 75 & PID_who == 3520009
replace type_voted = 7 if countryelection_FE == 75 & IMD3002_LH_PL == 3520009
replace type_PID = 7 if countryelection_FE == 75 & PID_who == 3520009

replace party_voted = 321 if countryelection_FE == 75 & IMD3002_LH_PL == 3520030 //* New Movement
replace party_PID = 321 if countryelection_FE == 75 & PID_who == 3520030
replace type_voted = 3 if countryelection_FE == 75 & IMD3002_LH_PL == 3520030
replace type_PID = 3 if countryelection_FE == 75 & PID_who == 3520030

//* Iceland 2003

replace incumbent_voted = 1 if countryelection_FE == 76 & inlist(IMD3002_LH_PL,3520001,3520003)  //* Independence - Progressive
replace incumbent_PID = 1 if countryelection_FE == 76 & inlist(PID_who,3520001,3520003)

replace party_voted = 93 if countryelection_FE == 76 & IMD3002_LH_PL == 3520001 //* Independence Party
replace party_PID = 93 if countryelection_FE == 76 & PID_who == 3520001
replace type_voted = 1 if countryelection_FE == 76 & IMD3002_LH_PL == 3520001
replace type_PID = 1 if countryelection_FE == 76 & PID_who == 3520001

replace party_voted = 94 if countryelection_FE == 76 & IMD3002_LH_PL == 3520002 | countryelection_FE == 76 & IMD3002_LH_PL == 3520019 //* SocDem Alliance
replace party_PID = 94 if countryelection_FE == 76 & PID_who == 3520002 | countryelection_FE == 76 & PID_who == 3520019
replace type_voted = 1 if countryelection_FE == 76 & IMD3002_LH_PL == 3520002 | countryelection_FE == 76 & IMD3002_LH_PL == 3520019
replace type_PID = 1 if countryelection_FE == 76 & PID_who == 3520002 | countryelection_FE == 76 & PID_who == 3520019

replace party_voted = 95 if countryelection_FE == 76 & IMD3002_LH_PL == 3520003 //* Progressive Alliance
replace party_PID = 95 if countryelection_FE == 76 & PID_who == 3520003
replace type_voted = 1 if countryelection_FE == 76 & IMD3002_LH_PL == 3520003
replace type_PID = 1 if countryelection_FE == 76 & PID_who == 3520003

replace party_voted = 96 if countryelection_FE == 76 & IMD3002_LH_PL == 3520004 //* Liberal Party
replace party_PID = 96 if countryelection_FE == 76 & PID_who == 3520004
replace type_voted = 3 if countryelection_FE == 76 & IMD3002_LH_PL == 3520004
replace type_PID = 3 if countryelection_FE == 76 & PID_who == 3520004

replace party_voted = 97 if countryelection_FE == 76 & IMD3002_LH_PL == 3520005 //* Left-Green Alliance
replace party_PID = 97 if countryelection_FE == 76 & PID_who == 3520005
replace type_voted = 6 if countryelection_FE == 76 & IMD3002_LH_PL == 3520005
replace type_PID = 6 if countryelection_FE == 76 & PID_who == 3520005

replace party_voted = 108 if countryelection_FE == 76 & IMD3002_LH_PL == 3520022 //* Humanist Party
replace party_PID = 108 if countryelection_FE == 76 & PID_who == 3520022
replace type_voted = 2 if countryelection_FE == 76 & IMD3002_LH_PL == 3520022
replace type_PID = 2 if countryelection_FE == 76 & PID_who == 3520022

replace party_voted = 110 if countryelection_FE == 76 & IMD3002_LH_PL == 3520026 //* Christian Democrats
replace party_PID = 110 if countryelection_FE == 76 & PID_who == 3520026
replace type_voted = 3 if countryelection_FE == 76 & IMD3002_LH_PL == 3520026
replace type_PID = 3 if countryelection_FE == 76 & PID_who == 3520026

replace party_voted = 111 if countryelection_FE == 76 & IMD3002_LH_PL == 3520027 //* Anarchists
replace party_PID = 111 if countryelection_FE == 76 & PID_who == 3520027
replace type_voted = 6 if countryelection_FE == 76 & IMD3002_LH_PL == 3520027
replace type_PID = 6 if countryelection_FE == 76 & PID_who == 3520027

replace party_voted = 348 if countryelection_FE == 76 & IMD3002_LH_PL == 3520017 //* Citizen's Movement
replace party_PID = 348 if countryelection_FE == 76 & PID_who == 3520017
replace type_voted = 7 if countryelection_FE == 76 & IMD3002_LH_PL == 3520017
replace type_PID = 7 if countryelection_FE == 76 & PID_who == 3520017

replace party_voted = 311 if countryelection_FE == 76 & IMD3002_LH_PL == 3520020 //* People's Alliance
replace party_PID = 311 if countryelection_FE == 76 & PID_who == 3520020
replace type_voted = 4 if countryelection_FE == 76 & IMD3002_LH_PL == 3520020
replace type_PID = 4 if countryelection_FE == 76 & PID_who == 3520020

replace party_voted = 349 if countryelection_FE == 76 & IMD3002_LH_PL == 3520024 //* Women's Alliance
replace party_PID = 349 if countryelection_FE == 76 & PID_who == 3520024
replace type_voted = 6 if countryelection_FE == 76 & IMD3002_LH_PL == 3520024
replace type_PID = 6 if countryelection_FE == 76 & PID_who == 3520024

replace party_voted = 100 if countryelection_FE == 76 & IMD3002_LH_PL == 3520009 //* Civic Movement
replace party_PID = 100 if countryelection_FE == 76 & PID_who == 3520009
replace type_voted = 7 if countryelection_FE == 76 & IMD3002_LH_PL == 3520009
replace type_PID = 7 if countryelection_FE == 76 & PID_who == 3520009

replace party_voted = 321 if countryelection_FE == 76 & IMD3002_LH_PL == 3520030 //* New Movement
replace party_PID = 321 if countryelection_FE == 76 & PID_who == 3520030
replace type_voted = 3 if countryelection_FE == 76 & IMD3002_LH_PL == 3520030
replace type_PID = 3 if countryelection_FE == 76 & PID_who == 3520030

//* Iceland 2007

replace incumbent_voted = 1 if countryelection_FE == 77 & inlist(IMD3002_LH_PL,3520001,3520003)  //* Independence - Progressive
replace incumbent_PID = 1 if countryelection_FE == 77 & inlist(PID_who,3520001,3520003)

replace party_voted = 93 if countryelection_FE == 77 & IMD3002_LH_PL == 3520001 //* Independence Party
replace party_PID = 93 if countryelection_FE == 77 & PID_who == 3520001
replace type_voted = 1 if countryelection_FE == 77 & IMD3002_LH_PL == 3520001
replace type_PID = 1 if countryelection_FE == 77 & PID_who == 3520001

replace party_voted = 94 if countryelection_FE == 77 & IMD3002_LH_PL == 3520002 | countryelection_FE == 77 & IMD3002_LH_PL == 3520019 //* SocDem Alliance
replace party_PID = 94 if countryelection_FE == 77 & PID_who == 3520002 | countryelection_FE == 77 & PID_who == 3520019
replace type_voted = 1 if countryelection_FE == 77 & IMD3002_LH_PL == 3520002 | countryelection_FE == 77 & IMD3002_LH_PL == 3520019
replace type_PID = 1 if countryelection_FE == 77 & PID_who == 3520002 | countryelection_FE == 77 & PID_who == 3520019

replace party_voted = 95 if countryelection_FE == 77 & IMD3002_LH_PL == 3520003 //* Progressive Alliance
replace party_PID = 95 if countryelection_FE == 77 & PID_who == 3520003
replace type_voted = 1 if countryelection_FE == 77 & IMD3002_LH_PL == 3520003
replace type_PID = 1 if countryelection_FE == 77 & PID_who == 3520003

replace party_voted = 96 if countryelection_FE == 77 & IMD3002_LH_PL == 3520004 //* Liberal Party
replace party_PID = 96 if countryelection_FE == 77 & PID_who == 3520004
replace type_voted = 7 if countryelection_FE == 77 & IMD3002_LH_PL == 3520004
replace type_PID = 7 if countryelection_FE == 77 & PID_who == 3520004

replace party_voted = 97 if countryelection_FE == 77 & IMD3002_LH_PL == 3520005 //* Left-Green Alliance
replace party_PID = 97 if countryelection_FE == 77 & PID_who == 3520005
replace type_voted = 6 if countryelection_FE == 77 & IMD3002_LH_PL == 3520005
replace type_PID = 6 if countryelection_FE == 77 & PID_who == 3520005

replace party_voted = 108 if countryelection_FE == 77 & IMD3002_LH_PL == 3520022 //* Humanist Party
replace party_PID = 108 if countryelection_FE == 77 & PID_who == 3520022
replace type_voted = 2 if countryelection_FE == 77 & IMD3002_LH_PL == 3520022
replace type_PID = 2 if countryelection_FE == 77 & PID_who == 3520022

replace party_voted = 110 if countryelection_FE == 77 & IMD3002_LH_PL == 3520026 //* Christian Democrats
replace party_PID = 110 if countryelection_FE == 77 & PID_who == 3520026
replace type_voted = 3 if countryelection_FE == 77 & IMD3002_LH_PL == 3520026
replace type_PID = 3 if countryelection_FE == 77 & PID_who == 3520026

replace party_voted = 111 if countryelection_FE == 77 & IMD3002_LH_PL == 3520027 //* Anarchists
replace party_PID = 111 if countryelection_FE == 77 & PID_who == 3520027
replace type_voted = 6 if countryelection_FE == 77 & IMD3002_LH_PL == 3520027
replace type_PID = 6 if countryelection_FE == 77 & PID_who == 3520027

replace party_voted = 102 if countryelection_FE == 77 & IMD3002_LH_PL == 3520013 //* Icelandic Movement
replace party_PID = 102 if countryelection_FE == 77 & PID_who == 3520013
replace type_voted = 2 if countryelection_FE == 77 & IMD3002_LH_PL == 3520013
replace type_PID = 2 if countryelection_FE == 77 & PID_who == 3520013

replace party_voted = 348 if countryelection_FE == 77 & IMD3002_LH_PL == 3520017 //* Citizen's Movement
replace party_PID = 348 if countryelection_FE == 77 & PID_who == 3520017
replace type_voted = 7 if countryelection_FE == 77 & IMD3002_LH_PL == 3520017
replace type_PID = 7 if countryelection_FE == 77 & PID_who == 3520017

replace party_voted = 311 if countryelection_FE == 77 & IMD3002_LH_PL == 3520020 //* People's Alliance
replace party_PID = 311 if countryelection_FE == 77 & PID_who == 3520020
replace type_voted = 4 if countryelection_FE == 77 & IMD3002_LH_PL == 3520020
replace type_PID = 4 if countryelection_FE == 77 & PID_who == 3520020

replace party_voted = 349 if countryelection_FE == 77 & IMD3002_LH_PL == 3520024 //* Women's Alliance
replace party_PID = 349 if countryelection_FE == 77 & PID_who == 3520024
replace type_voted = 6 if countryelection_FE == 77 & IMD3002_LH_PL == 3520024
replace type_PID = 6 if countryelection_FE == 77 & PID_who == 3520024

replace party_voted = 100 if countryelection_FE == 77 & IMD3002_LH_PL == 3520009 //* Civic Movement
replace party_PID = 100 if countryelection_FE == 77 & PID_who == 3520009
replace type_voted = 7 if countryelection_FE == 77 & IMD3002_LH_PL == 3520009
replace type_PID = 7 if countryelection_FE == 77 & PID_who == 3520009

replace party_voted = 321 if countryelection_FE == 77 & IMD3002_LH_PL == 3520030 //* New Movement
replace party_PID = 321 if countryelection_FE == 77 & PID_who == 3520030
replace type_voted = 3 if countryelection_FE == 77 & IMD3002_LH_PL == 3520030
replace type_PID = 3 if countryelection_FE == 77 & PID_who == 3520030

//* Iceland 2009

replace incumbent_voted = 1 if countryelection_FE == 78 & inlist(IMD3002_LH_PL,3520001,3520002)  //* Independence - SDA
replace incumbent_PID = 1 if countryelection_FE == 78 & inlist(PID_who,3520001,3520002)

replace party_voted = 93 if countryelection_FE == 78 & IMD3002_LH_PL == 3520001 //* Independence Party
replace party_PID = 93 if countryelection_FE == 78 & PID_who == 3520001
replace type_voted = 1 if countryelection_FE == 78 & IMD3002_LH_PL == 3520001
replace type_PID = 1 if countryelection_FE == 78 & PID_who == 3520001

replace party_voted = 94 if countryelection_FE == 78 & IMD3002_LH_PL == 3520002 | countryelection_FE == 78 & IMD3002_LH_PL == 3520019 //* SocDem Alliance
replace party_PID = 94 if countryelection_FE == 78 & PID_who == 3520002 | countryelection_FE == 78 & PID_who == 3520019
replace type_voted = 1 if countryelection_FE == 78 & IMD3002_LH_PL == 3520002 | countryelection_FE == 78 & IMD3002_LH_PL == 3520019
replace type_PID = 1 if countryelection_FE == 78 & PID_who == 3520002 | countryelection_FE == 78 & PID_who == 3520019

replace party_voted = 95 if countryelection_FE == 78 & IMD3002_LH_PL == 3520003 //* Progressive Alliance
replace party_PID = 95 if countryelection_FE == 78 & PID_who == 3520003
replace type_voted = 1 if countryelection_FE == 78 & IMD3002_LH_PL == 3520003
replace type_PID = 1 if countryelection_FE == 78 & PID_who == 3520003

replace party_voted = 96 if countryelection_FE == 78 & IMD3002_LH_PL == 3520004 //* Liberal Party
replace party_PID = 96 if countryelection_FE == 78 & PID_who == 3520004
replace type_voted = 7 if countryelection_FE == 78 & IMD3002_LH_PL == 3520004
replace type_PID = 7 if countryelection_FE == 78 & PID_who == 3520004

replace party_voted = 97 if countryelection_FE == 78 & IMD3002_LH_PL == 3520005 //* Left-Green Alliance
replace party_PID = 97 if countryelection_FE == 78 & PID_who == 3520005
replace type_voted = 6 if countryelection_FE == 78 & IMD3002_LH_PL == 3520005
replace type_PID = 6 if countryelection_FE == 78 & PID_who == 3520005

replace party_voted = 108 if countryelection_FE == 78 & IMD3002_LH_PL == 3520022 //* Humanist Party
replace party_PID = 108 if countryelection_FE == 78 & PID_who == 3520022
replace type_voted = 2 if countryelection_FE == 78 & IMD3002_LH_PL == 3520022
replace type_PID = 2 if countryelection_FE == 78 & PID_who == 3520022

replace party_voted = 110 if countryelection_FE == 78 & IMD3002_LH_PL == 3520026 //* Christian Democrats
replace party_PID = 110 if countryelection_FE == 78 & PID_who == 3520026
replace type_voted = 3 if countryelection_FE == 78 & IMD3002_LH_PL == 3520026
replace type_PID = 3 if countryelection_FE == 78 & PID_who == 3520026

replace party_voted = 111 if countryelection_FE == 78 & IMD3002_LH_PL == 3520027 //* Anarchists
replace party_PID = 111 if countryelection_FE == 78 & PID_who == 3520027
replace type_voted = 6 if countryelection_FE == 78 & IMD3002_LH_PL == 3520027
replace type_PID = 6 if countryelection_FE == 78 & PID_who == 3520027

replace party_voted = 102 if countryelection_FE == 78 & IMD3002_LH_PL == 3520013 //* Icelandic Movement
replace party_PID = 102 if countryelection_FE == 78 & PID_who == 3520013
replace type_voted = 2 if countryelection_FE == 78 & IMD3002_LH_PL == 3520013
replace type_PID = 2 if countryelection_FE == 78 & PID_who == 3520013

replace party_voted = 348 if countryelection_FE == 78 & IMD3002_LH_PL == 3520017 //* Citizen's Movement
replace party_PID = 348 if countryelection_FE == 78 & PID_who == 3520017
replace type_voted = 7 if countryelection_FE == 78 & IMD3002_LH_PL == 3520017
replace type_PID = 7 if countryelection_FE == 78 & PID_who == 3520017

replace party_voted = 106 if countryelection_FE == 78 & IMD3002_LH_PL == 3520018 //* Democratic Movement
replace party_PID = 106 if countryelection_FE == 78 & PID_who == 3520018
replace type_voted = 7 if countryelection_FE == 78 & IMD3002_LH_PL == 3520018
replace type_PID = 7 if countryelection_FE == 78 & PID_who == 3520018

replace party_voted = 311 if countryelection_FE == 78 & IMD3002_LH_PL == 3520020 //* People's Alliance
replace party_PID = 311 if countryelection_FE == 78 & PID_who == 3520020
replace type_voted = 4 if countryelection_FE == 78 & IMD3002_LH_PL == 3520020
replace type_PID = 4 if countryelection_FE == 78 & PID_who == 3520020

replace party_voted = 349 if countryelection_FE == 78 & IMD3002_LH_PL == 3520024 //* Women's Alliance
replace party_PID = 349 if countryelection_FE == 78 & PID_who == 3520024
replace type_voted = 6 if countryelection_FE == 78 & IMD3002_LH_PL == 3520024
replace type_PID = 6 if countryelection_FE == 78 & PID_who == 3520024

replace party_voted = 100 if countryelection_FE == 78 & IMD3002_LH_PL == 3520009 //* Civic Movement
replace party_PID = 100 if countryelection_FE == 78 & PID_who == 3520009
replace type_voted = 7 if countryelection_FE == 78 & IMD3002_LH_PL == 3520009
replace type_PID = 7 if countryelection_FE == 78 & PID_who == 3520009

//* Iceland 2013

replace incumbent_voted = 1 if countryelection_FE == 79 & inlist(IMD3002_LH_PL,3520002,3520005)  //* SDA - Left-Green Movement
replace incumbent_PID = 1 if countryelection_FE == 79 & inlist(PID_who,3520002,3520005)

replace party_voted = 93 if countryelection_FE == 79 & IMD3002_LH_PL == 3520001 //* Independence Party
replace party_PID = 93 if countryelection_FE == 79 & PID_who == 3520001
replace type_voted = 1 if countryelection_FE == 79 & IMD3002_LH_PL == 3520001
replace type_PID = 1 if countryelection_FE == 79 & PID_who == 3520001

replace party_voted = 94 if countryelection_FE == 79 & IMD3002_LH_PL == 3520002 | countryelection_FE == 79 & IMD3002_LH_PL == 3520019 //* SocDem Alliance
replace party_PID = 94 if countryelection_FE == 79 & PID_who == 3520002 | countryelection_FE == 79 & PID_who == 3520019
replace type_voted = 1 if countryelection_FE == 79 & IMD3002_LH_PL == 3520002 | countryelection_FE == 79 & IMD3002_LH_PL == 3520019
replace type_PID = 1 if countryelection_FE == 79 & PID_who == 3520002 | countryelection_FE == 79 & PID_who == 3520019

replace party_voted = 95 if countryelection_FE == 79 & IMD3002_LH_PL == 3520003 //* Progressive Alliance
replace party_PID = 95 if countryelection_FE == 79 & PID_who == 3520003
replace type_voted = 1 if countryelection_FE == 79 & IMD3002_LH_PL == 3520003
replace type_PID = 1 if countryelection_FE == 79 & PID_who == 3520003

replace party_voted = 96 if countryelection_FE == 79 & IMD3002_LH_PL == 3520004 //* Liberal Party
replace party_PID = 96 if countryelection_FE == 79 & PID_who == 3520004
replace type_voted = 7 if countryelection_FE == 79 & IMD3002_LH_PL == 3520004
replace type_PID = 7 if countryelection_FE == 79 & PID_who == 3520004

replace party_voted = 97 if countryelection_FE == 79 & IMD3002_LH_PL == 3520005 //* Left-Green Alliance
replace party_PID = 97 if countryelection_FE == 79 & PID_who == 3520005
replace type_voted = 4 if countryelection_FE == 79 & IMD3002_LH_PL == 3520005
replace type_PID = 4 if countryelection_FE == 79 & PID_who == 3520005

replace party_voted = 98 if countryelection_FE == 79 & IMD3002_LH_PL == 3520007 //* Bright Future
replace party_PID = 98 if countryelection_FE == 79 & PID_who == 3520007
replace type_voted = 6 if countryelection_FE == 79 & IMD3002_LH_PL == 3520007
replace type_PID = 6 if countryelection_FE == 79 & PID_who == 3520007

replace party_voted = 99 if countryelection_FE == 79 & IMD3002_LH_PL == 3520008 //* Pirate Party
replace party_PID = 99 if countryelection_FE == 79 & PID_who == 3520008
replace type_voted = 6 if countryelection_FE == 79 & IMD3002_LH_PL == 3520008
replace type_PID = 6 if countryelection_FE == 79 & PID_who == 3520008

replace party_voted = 101 if countryelection_FE == 79 & IMD3002_LH_PL == 3520012 //* Right-Green People's Party
replace party_PID = 101 if countryelection_FE == 79 & PID_who == 3520012
replace type_voted = 3 if countryelection_FE == 79 & IMD3002_LH_PL == 3520012
replace type_PID = 3 if countryelection_FE == 79 & PID_who == 3520012

replace party_voted = 103 if countryelection_FE == 79 & IMD3002_LH_PL == 3520014 //* Dawn
replace party_PID = 103 if countryelection_FE == 79 & PID_who == 3520014
replace type_voted = 7 if countryelection_FE == 79 & IMD3002_LH_PL == 3520014
replace type_PID = 7 if countryelection_FE == 79 & PID_who == 3520014

replace party_voted = 108 if countryelection_FE == 79 & IMD3002_LH_PL == 3520022 //* Humanist Party
replace party_PID = 108 if countryelection_FE == 79 & PID_who == 3520022
replace type_voted = 2 if countryelection_FE == 79 & IMD3002_LH_PL == 3520022
replace type_PID = 2 if countryelection_FE == 79 & PID_who == 3520022

replace party_voted = 110 if countryelection_FE == 79 & IMD3002_LH_PL == 3520026 //* Christian Democrats
replace party_PID = 110 if countryelection_FE == 79 & PID_who == 3520026
replace type_voted = 3 if countryelection_FE == 79 & IMD3002_LH_PL == 3520026
replace type_PID = 3 if countryelection_FE == 79 & PID_who == 3520026

replace party_voted = 111 if countryelection_FE == 79 & IMD3002_LH_PL == 3520027 //* Anarchists
replace party_PID = 111 if countryelection_FE == 79 & PID_who == 3520027
replace type_voted = 6 if countryelection_FE == 79 & IMD3002_LH_PL == 3520027
replace type_PID = 6 if countryelection_FE == 79 & PID_who == 3520027

replace party_voted = 102 if countryelection_FE == 79 & IMD3002_LH_PL == 3520013 //* Icelandic Movement
replace party_PID = 102 if countryelection_FE == 79 & PID_who == 3520013
replace type_voted = 2 if countryelection_FE == 79 & IMD3002_LH_PL == 3520013
replace type_PID = 2 if countryelection_FE == 79 & PID_who == 3520013

replace party_voted = 104 if countryelection_FE == 79 & IMD3002_LH_PL == 3520015 //* Icelandic Democratic Party
replace party_PID = 104 if countryelection_FE == 79 & PID_who == 3520015
replace type_voted = 7 if countryelection_FE == 79 & IMD3002_LH_PL == 3520015
replace type_PID = 7 if countryelection_FE == 79 & PID_who == 3520015

replace party_voted = 105 if countryelection_FE == 79 & IMD3002_LH_PL == 3520016 //* Rainbow
replace party_PID = 105 if countryelection_FE == 79 & PID_who == 3520016
replace type_voted = 6 if countryelection_FE == 79 & IMD3002_LH_PL == 3520016
replace type_PID = 6 if countryelection_FE == 79 & PID_who == 3520016

replace party_voted = 348 if countryelection_FE == 79 & IMD3002_LH_PL == 3520017 //* Citizen's Movement
replace party_PID = 348 if countryelection_FE == 79 & PID_who == 3520017
replace type_voted = 7 if countryelection_FE == 79 & IMD3002_LH_PL == 3520017
replace type_PID = 7 if countryelection_FE == 79 & PID_who == 3520017

replace party_voted = 106 if countryelection_FE == 79 & IMD3002_LH_PL == 3520018 //* Democratic Movement
replace party_PID = 106 if countryelection_FE == 79 & PID_who == 3520018
replace type_voted = 6 if countryelection_FE == 79 & IMD3002_LH_PL == 3520018
replace type_PID = 6 if countryelection_FE == 79 & PID_who == 3520018

replace party_voted = 311 if countryelection_FE == 79 & IMD3002_LH_PL == 3520020 //* People's Alliance
replace party_PID = 311 if countryelection_FE == 79 & PID_who == 3520020
replace type_voted = 4 if countryelection_FE == 79 & IMD3002_LH_PL == 3520020
replace type_PID = 4 if countryelection_FE == 79 & PID_who == 3520020

replace party_voted = 349 if countryelection_FE == 79 & IMD3002_LH_PL == 3520024 //* Women's Alliance
replace party_PID = 349 if countryelection_FE == 79 & PID_who == 3520024
replace type_voted = 6 if countryelection_FE == 79 & IMD3002_LH_PL == 3520024
replace type_PID = 6 if countryelection_FE == 79 & PID_who == 3520024

replace party_voted = 107 if countryelection_FE == 79 & IMD3002_LH_PL == 3520021 //* Household's Party
replace party_PID = 107 if countryelection_FE == 79 & PID_who == 3520021
replace type_voted = 3 if countryelection_FE == 79 & IMD3002_LH_PL == 3520021
replace type_PID = 3 if countryelection_FE == 79 & PID_who == 3520021

replace party_voted = 109 if countryelection_FE == 79 & IMD3002_LH_PL == 3520025 //* Rural Party
replace party_PID = 109 if countryelection_FE == 79 & PID_who == 3520025
replace type_voted = 3 if countryelection_FE == 79 & IMD3002_LH_PL == 3520025
replace type_PID = 3 if countryelection_FE == 79 & PID_who == 3520025

replace party_voted = 100 if countryelection_FE == 79 & IMD3002_LH_PL == 3520009 //* Civic Movement
replace party_PID = 100 if countryelection_FE == 79 & PID_who == 3520009
replace type_voted = 7 if countryelection_FE == 79 & IMD3002_LH_PL == 3520009
replace type_PID = 7 if countryelection_FE == 79 & PID_who == 3520009

//* Italy 2006

replace incumbent_voted = 1 if countryelection_FE == 84 & inlist(IMD3002_LH_PL,3800002,3800003,3800012,3800022,3800029,3800040)  //* Forza Italia - Nat Alliance - Lega Nord - UDC - Ital Socialists - Italian Republicans
replace incumbent_PID = 1 if countryelection_FE == 84 & inlist(PID_who,3800002,3800003,3800012,3800022,3800029,3800040)

replace party_voted = 112 if countryelection_FE == 84 & IMD3002_LH_PL == 3800002 | IMD3002_LH_PL == 3800040 //* Forza Italia
replace party_PID = 112 if countryelection_FE == 84 & PID_who == 3800002 | PID_who == 3800040
replace type_voted = 1 if countryelection_FE == 84 & IMD3002_LH_PL == 3800002 | IMD3002_LH_PL == 3800040
replace type_PID = 1 if countryelection_FE == 84 & PID_who == 3800002 | PID_who == 3800040

replace party_voted = 113 if countryelection_FE == 84 & IMD3002_LH_PL == 3800003 //* Lega Nord
replace party_PID = 113 if countryelection_FE == 84 & PID_who == 3800003
replace type_voted = 5 if countryelection_FE == 84 & IMD3002_LH_PL == 3800003
replace type_PID = 5 if countryelection_FE == 84 & PID_who == 3800003

replace party_voted = 114 if countryelection_FE == 84 & IMD3002_LH_PL == 3800005 //* Greens
replace party_PID = 114 if countryelection_FE == 84 & PID_who == 3800005
replace type_voted = 1 if countryelection_FE == 84 & IMD3002_LH_PL == 3800005
replace type_PID = 1 if countryelection_FE == 84 & PID_who == 3800005

replace party_voted = 115 if countryelection_FE == 84 & IMD3002_LH_PL == 3800009 //* Party of Italian Communists
replace party_PID = 115 if countryelection_FE == 84 & PID_who == 3800009
replace type_voted = 4 if countryelection_FE == 84 & IMD3002_LH_PL == 3800009
replace type_PID = 4 if countryelection_FE == 84 & PID_who == 3800009

replace party_voted = 116 if countryelection_FE == 84 & IMD3002_LH_PL == 3800012 //* Union of Christians and Centrists
replace party_PID = 116 if countryelection_FE == 84 & PID_who == 3800012
replace type_voted = 1 if countryelection_FE == 84 & IMD3002_LH_PL == 3800012
replace type_PID = 1 if countryelection_FE == 84 & PID_who == 3800012

replace party_voted = 117 if countryelection_FE == 84 & IMD3002_LH_PL == 3800013 //* Communist Refoundation Party
replace party_PID = 117 if countryelection_FE == 84 & PID_who == 3800013
replace type_voted = 4 if countryelection_FE == 84 & IMD3002_LH_PL == 3800013
replace type_PID = 4 if countryelection_FE == 84 & PID_who == 3800013

replace party_voted = 118 if countryelection_FE == 84 & IMD3002_LH_PL == 3800014 //* Rose in the Fist
replace party_PID = 118 if countryelection_FE == 84 & PID_who == 3800014
replace type_voted = 2 if countryelection_FE == 84 & IMD3002_LH_PL == 3800014
replace type_PID = 2 if countryelection_FE == 84 & PID_who == 3800014

replace party_voted = 322 if countryelection_FE == 84 & IMD3002_LH_PL == 3800015 //* Italy of Values
replace party_PID = 322 if countryelection_FE == 84 & PID_who == 3800015
replace type_voted = 2 if countryelection_FE == 84 & IMD3002_LH_PL == 3800015
replace type_PID = 2 if countryelection_FE == 84 & PID_who == 3800015

replace party_voted = 119 if countryelection_FE == 84 & IMD3002_LH_PL == 3800022 //* National Alliance
replace party_PID = 119 if countryelection_FE == 84 & PID_who == 3800022
replace type_voted = 5 if countryelection_FE == 84 & IMD3002_LH_PL == 3800022
replace type_PID = 5 if countryelection_FE == 84 & PID_who == 3800022

replace party_voted = 120 if countryelection_FE == 84 & IMD3002_LH_PL == 3800024 //* Popular-UDEUR
replace party_PID = 120 if countryelection_FE == 84 & PID_who == 3800024
replace type_voted = 1 if countryelection_FE == 84 & IMD3002_LH_PL == 3800024
replace type_PID = 1 if countryelection_FE == 84 & PID_who == 3800024

replace party_voted = 121 if countryelection_FE == 84 & IMD3002_LH_PL == 3800026 //* Christian Democracy
replace party_PID = 121 if countryelection_FE == 84 & PID_who == 3800026
replace type_voted = 1 if countryelection_FE == 84 & IMD3002_LH_PL == 3800026
replace type_PID = 1 if countryelection_FE == 84 & PID_who == 3800026

replace party_voted = 122 if countryelection_FE == 84 & IMD3002_LH_PL == 3800027 //* Social Alternative
replace party_PID = 122 if countryelection_FE == 84 & PID_who == 3800027
replace type_voted = 6 if countryelection_FE == 84 & IMD3002_LH_PL == 3800027
replace type_PID = 6 if countryelection_FE == 84 & PID_who == 3800027

replace party_voted = 123 if countryelection_FE == 84 & IMD3002_LH_PL == 3800028 //* Tricolour Flame
replace party_PID = 123 if countryelection_FE == 84 & PID_who == 3800028
replace type_voted = 7 if countryelection_FE == 84 & IMD3002_LH_PL == 3800028
replace type_PID = 7 if countryelection_FE == 84 & PID_who == 3800028

replace party_voted = 124 if countryelection_FE == 84 & IMD3002_LH_PL == 3800029 //* The Socialists
replace party_PID = 124 if countryelection_FE == 84 & PID_who == 3800029
replace type_voted = 1 if countryelection_FE == 84 & IMD3002_LH_PL == 3800029
replace type_PID = 1 if countryelection_FE == 84 & PID_who == 3800029

replace party_voted = 125 if countryelection_FE == 84 & IMD3002_LH_PL == 3800034 //* Terzo Polo 
replace party_PID = 125 if countryelection_FE == 84 & PID_who == 3800034
replace type_voted = 3 if countryelection_FE == 84 & IMD3002_LH_PL == 3800034
replace type_PID = 3 if countryelection_FE == 84 & PID_who == 3800034

replace party_voted = 126 if countryelection_FE == 84 & IMD3002_LH_PL == 3800035 //* Solidarieta
replace party_PID = 126 if countryelection_FE == 84 & PID_who == 3800035
replace type_voted = 2 if countryelection_FE == 84 & IMD3002_LH_PL == 3800035
replace type_PID = 2 if countryelection_FE == 84 & PID_who == 3800035

replace party_voted = 127 if countryelection_FE == 84 & IMD3002_LH_PL == 3800036 //* Pensioner's Party
replace party_PID = 127 if countryelection_FE == 84 & PID_who == 3800036
replace type_voted = 1 if countryelection_FE == 84 & IMD3002_LH_PL == 3800036
replace type_PID = 1 if countryelection_FE == 84 & PID_who == 3800036

replace party_voted = 128 if countryelection_FE == 84 & IMD3002_LH_PL == 3800038 | IMD3002_LH_PL == 3800039 | IMD3002_LH_PL ==  3800011 //* The Olive / Democrats of the Left
replace party_PID = 128 if countryelection_FE == 84 & PID_who == 3800038 | PID_who == 3800039 | PID_who == 3800011 
replace type_voted = 1 if countryelection_FE == 84 & IMD3002_LH_PL == 3800038 | IMD3002_LH_PL == 3800039 | IMD3002_LH_PL == 3800011 
replace type_PID = 1 if countryelection_FE == 84 & PID_who == 3800038 | PID_who == 3800039 | PID_who == 3800011 

replace party_voted = 323 if countryelection_FE == 84 & IMD3002_LH_PL == 3800021 //* The Daisy
replace party_PID = 323 if countryelection_FE == 84 & PID_who == 3800021
replace type_voted = 1 if countryelection_FE == 84 & IMD3002_LH_PL == 3800021
replace type_PID = 1 if countryelection_FE == 84 & PID_who == 3800021


//* Netherlands 1998

replace incumbent_voted = 1 if countryelection_FE == 107 & inlist(IMD3002_LH_PL,5280002,5280003,5280004)  //* 	Labour Party, VVD, D66
replace incumbent_PID = 1 if countryelection_FE == 107 & inlist(PID_who,5280002,5280003,5280004)

replace party_voted = 129 if countryelection_FE == 107 & IMD3002_LH_PL == 5280001 //* CDA
replace party_PID = 129 if countryelection_FE == 107 & PID_who == 5280001
replace type_voted = 1 if countryelection_FE == 107 & IMD3002_LH_PL == 5280001
replace type_PID = 1 if countryelection_FE == 107 & PID_who == 5280001

replace party_voted = 130 if countryelection_FE == 107 & IMD3002_LH_PL == 5280002 //* Labour Party
replace party_PID = 130 if countryelection_FE == 107 & PID_who == 5280002
replace type_voted = 1 if countryelection_FE == 107 & IMD3002_LH_PL == 5280002
replace type_PID = 1 if countryelection_FE == 107 & PID_who == 5280002

replace party_voted = 131 if countryelection_FE == 107 & IMD3002_LH_PL == 5280003 //* People's Party for Freedom and Democracy
replace party_PID = 131 if countryelection_FE == 107 & PID_who == 5280003
replace type_voted = 1 if countryelection_FE == 107 & IMD3002_LH_PL == 5280003
replace type_PID = 1 if countryelection_FE == 107 & PID_who == 5280003

replace party_voted = 132 if countryelection_FE == 107 & IMD3002_LH_PL == 5280004 //* Democrats 66
replace party_PID = 132 if countryelection_FE == 107 & PID_who == 5280004
replace type_voted = 4 if countryelection_FE == 107 & IMD3002_LH_PL == 5280004
replace type_PID = 4 if countryelection_FE == 107 & PID_who == 5280004

replace party_voted = 133 if countryelection_FE == 107 & IMD3002_LH_PL == 5280005 //* GreenLeft
replace party_PID = 133 if countryelection_FE == 107 & PID_who == 5280005
replace type_voted = 6 if countryelection_FE == 107 & IMD3002_LH_PL == 5280005
replace type_PID = 6 if countryelection_FE == 107 & PID_who == 5280005

replace party_voted = 134 if countryelection_FE == 107 & IMD3002_LH_PL == 5280006 //* Socialist Party
replace party_PID = 134 if countryelection_FE == 107 & PID_who == 5280006
replace type_voted = 6 if countryelection_FE == 107 & IMD3002_LH_PL == 5280006
replace type_PID = 6 if countryelection_FE == 107 & PID_who == 5280006

replace party_voted = 135 if countryelection_FE == 107 & IMD3002_LH_PL == 5280007 //* Reformed Party
replace party_PID = 135 if countryelection_FE == 107 & PID_who == 5280007
replace type_voted = 7 if countryelection_FE == 107 & IMD3002_LH_PL == 5280007
replace type_PID = 7 if countryelection_FE == 107 & PID_who == 5280007

replace party_voted = 144 if countryelection_FE == 107 & IMD3002_LH_PL == 5280017 //* United Senior's Party
replace party_PID = 144 if countryelection_FE == 107 & PID_who == 5280017
replace type_voted = 3 if countryelection_FE == 107 & IMD3002_LH_PL == 5280017
replace type_PID = 3 if countryelection_FE == 107 & PID_who == 5280017

replace party_voted = 145 if countryelection_FE == 107 & IMD3002_LH_PL == 5280021 //* Centre Democrats
replace party_PID = 145 if countryelection_FE == 107 & PID_who == 5280021
replace type_voted = 7 if countryelection_FE == 107 & IMD3002_LH_PL == 5280021
replace type_PID = 7 if countryelection_FE == 107 & PID_who == 5280021

replace party_voted = 146 if countryelection_FE == 107 & IMD3002_LH_PL == 5280026 //* Reformed Political Alliance
replace party_PID = 146 if countryelection_FE == 107 & PID_who == 5280026
replace type_voted = 7 if countryelection_FE == 107 & IMD3002_LH_PL == 5280026
replace type_PID = 7 if countryelection_FE == 107 & PID_who == 5280026

replace party_voted = 147 if countryelection_FE == 107 & IMD3002_LH_PL == 5280027 //* Dutch Greens
replace party_PID = 147 if countryelection_FE == 107 & PID_who == 5280027
replace type_voted = 6 if countryelection_FE == 107 & IMD3002_LH_PL == 5280027
replace type_PID = 6 if countryelection_FE == 107 & PID_who == 5280027

replace party_voted = 148 if countryelection_FE == 107 & IMD3002_LH_PL == 5280030 //* Natural Law Party
replace party_PID = 148 if countryelection_FE == 107 & PID_who == 5280030
replace type_voted = 2 if countryelection_FE == 107 & IMD3002_LH_PL == 5280030
replace type_PID = 2 if countryelection_FE == 107 & PID_who == 5280030

replace party_voted = 150 if countryelection_FE == 107 & IMD3002_LH_PL == 5280035 //* Reformed Federation
replace party_PID = 150 if countryelection_FE == 107 & PID_who == 5280035
replace type_voted = 7 if countryelection_FE == 107 & IMD3002_LH_PL == 5280035
replace type_PID = 7 if countryelection_FE == 107 & PID_who == 5280035

replace party_voted = 151 if countryelection_FE == 107 & IMD3002_LH_PL == 5280038 //* Free Indian Party
replace party_PID = 151 if countryelection_FE == 107 & PID_who == 5280038
replace type_voted = 3 if countryelection_FE == 107 & IMD3002_LH_PL == 5280038
replace type_PID = 3 if countryelection_FE == 107 & PID_who == 5280038

replace party_voted = 152 if countryelection_FE == 107 & IMD3002_LH_PL == 5280040 //* Union 55+
replace party_PID = 152 if countryelection_FE == 107 & PID_who == 5280040 
replace type_voted = 3 if countryelection_FE == 107 & IMD3002_LH_PL == 5280040 
replace type_PID = 3 if countryelection_FE == 107 & PID_who == 5280040 

replace party_voted = 153 if countryelection_FE == 107 & IMD3002_LH_PL == 5280041 //* Seniors 2000
replace party_PID = 153 if countryelection_FE == 107 & PID_who == 5280041 
replace type_voted = 3 if countryelection_FE == 107 & IMD3002_LH_PL == 5280041 
replace type_PID = 3 if countryelection_FE == 107 & PID_who == 5280041 

replace party_voted = 154 if countryelection_FE == 107 & IMD3002_LH_PL == 5280042 //* Mobile Netherlands
replace party_PID = 154 if countryelection_FE == 107 & PID_who == 5280042
replace type_voted = 2 if countryelection_FE == 107 & IMD3002_LH_PL == 5280042
replace type_PID = 2 if countryelection_FE == 107 & PID_who == 5280042

replace party_voted = 142 if countryelection_FE == 107 & IMD3002_LH_PL == 5280015 //* Local List
replace party_PID = 142 if countryelection_FE == 107 & PID_who == 5280015
replace type_voted = 2 if countryelection_FE == 107 & IMD3002_LH_PL == 5280015
replace type_PID = 2 if countryelection_FE == 107 & PID_who == 5280015

replace party_voted = 326 if countryelection_FE == 107 & IMD3002_LH_PL == 5280023 //* Communists
replace party_PID = 326 if countryelection_FE == 107 & PID_who == 5280023
replace type_voted = 6 if countryelection_FE == 107 & IMD3002_LH_PL == 5280023
replace type_PID = 6 if countryelection_FE == 107 & PID_who == 5280023

replace party_voted = 327 if countryelection_FE == 107 & IMD3002_LH_PL == 5280033 //* Pacifist Socialist Party
replace party_PID = 327 if countryelection_FE == 107 & PID_who == 5280033
replace type_voted = 6 if countryelection_FE == 107 & IMD3002_LH_PL == 5280033
replace type_PID = 6 if countryelection_FE == 107 & PID_who == 5280033



//* Netherlands 2002

replace incumbent_voted = 1 if countryelection_FE == 108 & inlist(IMD3002_LH_PL,5280002,5280003,5280004)  //* 	Labour Party, VVD, D66
replace incumbent_PID = 1 if countryelection_FE == 108 & inlist(PID_who,5280002,5280003,5280004)

replace party_voted = 129 if countryelection_FE == 108 & IMD3002_LH_PL == 5280001 //* CDA
replace party_PID = 129 if countryelection_FE == 108 & PID_who == 5280001
replace type_voted = 1 if countryelection_FE == 108 & IMD3002_LH_PL == 5280001
replace type_PID = 1 if countryelection_FE == 108 & PID_who == 5280001

replace party_voted = 130 if countryelection_FE == 108 & IMD3002_LH_PL == 5280002 //* Labour Party
replace party_PID = 130 if countryelection_FE == 108 & PID_who == 5280002
replace type_voted = 1 if countryelection_FE == 108 & IMD3002_LH_PL == 5280002
replace type_PID = 1 if countryelection_FE == 108 & PID_who == 5280002

replace party_voted = 131 if countryelection_FE == 108 & IMD3002_LH_PL == 5280003 //* People's Party for Freedom and Democracy
replace party_PID = 131 if countryelection_FE == 108 & PID_who == 5280003
replace type_voted = 1 if countryelection_FE == 108 & IMD3002_LH_PL == 5280003
replace type_PID = 1 if countryelection_FE == 108 & PID_who == 5280003

replace party_voted = 132 if countryelection_FE == 108 & IMD3002_LH_PL == 5280004 //* Democrats 66
replace party_PID = 132 if countryelection_FE == 108 & PID_who == 5280004
replace type_voted = 4 if countryelection_FE == 108 & IMD3002_LH_PL == 5280004
replace type_PID = 4 if countryelection_FE == 108 & PID_who == 5280004

replace party_voted = 133 if countryelection_FE == 108 & IMD3002_LH_PL == 5280005 //* GreenLeft
replace party_PID = 133 if countryelection_FE == 108 & PID_who == 5280005
replace type_voted = 6 if countryelection_FE == 108 & IMD3002_LH_PL == 5280005
replace type_PID = 6 if countryelection_FE == 108 & PID_who == 5280005

replace party_voted = 134 if countryelection_FE == 108 & IMD3002_LH_PL == 5280006 //* Socialist Party
replace party_PID = 134 if countryelection_FE == 108 & PID_who == 5280006
replace type_voted = 6 if countryelection_FE == 108 & IMD3002_LH_PL == 5280006
replace type_PID = 6 if countryelection_FE == 108 & PID_who == 5280006

replace party_voted = 135 if countryelection_FE == 108 & IMD3002_LH_PL == 5280007 //* Reformed Party
replace party_PID = 135 if countryelection_FE == 108 & PID_who == 5280007
replace type_voted = 7 if countryelection_FE == 108 & IMD3002_LH_PL == 5280007
replace type_PID = 7 if countryelection_FE == 108 & PID_who == 5280007

replace party_voted = 136 if countryelection_FE == 108 & IMD3002_LH_PL == 5280008 //* Christian Union
replace party_PID = 136 if countryelection_FE == 108 & PID_who == 5280008
replace type_voted = 3 if countryelection_FE == 108 & IMD3002_LH_PL == 5280008
replace type_PID = 3 if countryelection_FE == 108 & PID_who == 5280008

replace party_voted = 144 if countryelection_FE == 108 & IMD3002_LH_PL == 5280017 //* United Senior's Party
replace party_PID = 144 if countryelection_FE == 108 & PID_who == 5280017
replace type_voted = 3 if countryelection_FE == 108 & IMD3002_LH_PL == 5280017
replace type_PID = 3 if countryelection_FE == 108 & PID_who == 5280017

replace party_voted = 145 if countryelection_FE == 108 & IMD3002_LH_PL == 5280021 //* Centre Democrats
replace party_PID = 145 if countryelection_FE == 108 & PID_who == 5280021
replace type_voted = 7 if countryelection_FE == 108 & IMD3002_LH_PL == 5280021
replace type_PID = 7 if countryelection_FE == 108 & PID_who == 5280021

replace party_voted = 146 if countryelection_FE == 108 & IMD3002_LH_PL == 5280026 //* Reformed Political Alliance
replace party_PID = 146 if countryelection_FE == 108 & PID_who == 5280026
replace type_voted = 7 if countryelection_FE == 108 & IMD3002_LH_PL == 5280026
replace type_PID = 7 if countryelection_FE == 108 & PID_who == 5280026

replace party_voted = 147 if countryelection_FE == 108 & IMD3002_LH_PL == 5280027 //* Dutch Greens
replace party_PID = 147 if countryelection_FE == 108 & PID_who == 5280027
replace type_voted = 6 if countryelection_FE == 108 & IMD3002_LH_PL == 5280027
replace type_PID = 6 if countryelection_FE == 108 & PID_who == 5280027

replace party_voted = 148 if countryelection_FE == 108 & IMD3002_LH_PL == 5280030 //* Natural Law Party
replace party_PID = 148 if countryelection_FE == 108 & PID_who == 5280030
replace type_voted = 2 if countryelection_FE == 108 & IMD3002_LH_PL == 5280030
replace type_PID = 2 if countryelection_FE == 108 & PID_who == 5280030

replace party_voted = 150 if countryelection_FE == 108 & IMD3002_LH_PL == 5280035 //* Reformed Federation
replace party_PID = 150 if countryelection_FE == 108 & PID_who == 5280035
replace type_voted = 7 if countryelection_FE == 108 & IMD3002_LH_PL == 5280035
replace type_PID = 7 if countryelection_FE == 108 & PID_who == 5280035

replace party_voted = 151 if countryelection_FE == 108 & IMD3002_LH_PL == 5280038 //* Free Indian Party
replace party_PID = 151 if countryelection_FE == 108 & PID_who == 5280038
replace type_voted = 3 if countryelection_FE == 108 & IMD3002_LH_PL == 5280038
replace type_PID = 3 if countryelection_FE == 108 & PID_who == 5280038

replace party_voted = 152 if countryelection_FE == 108 & IMD3002_LH_PL == 5280040 //* Union 55+
replace party_PID = 152 if countryelection_FE == 108 & PID_who == 5280040 
replace type_voted = 3 if countryelection_FE == 108 & IMD3002_LH_PL == 5280040 
replace type_PID = 3 if countryelection_FE == 108 & PID_who == 5280040 

replace party_voted = 153 if countryelection_FE == 108 & IMD3002_LH_PL == 5280041 //* Seniors 2000
replace party_PID = 153 if countryelection_FE == 108 & PID_who == 5280041 
replace type_voted = 3 if countryelection_FE == 108 & IMD3002_LH_PL == 5280041 
replace type_PID = 3 if countryelection_FE == 108 & PID_who == 5280041 

replace party_voted = 154 if countryelection_FE == 108 & IMD3002_LH_PL == 5280042 //* Mobile Netherlands
replace party_PID = 154 if countryelection_FE == 108 & PID_who == 5280042
replace type_voted = 2 if countryelection_FE == 108 & IMD3002_LH_PL == 5280042
replace type_PID = 2 if countryelection_FE == 108 & PID_who == 5280042

replace party_voted = 142 if countryelection_FE == 108 & IMD3002_LH_PL == 5280015 //* Local List
replace party_PID = 142 if countryelection_FE == 108 & PID_who == 5280015
replace type_voted = 2 if countryelection_FE == 108 & IMD3002_LH_PL == 5280015
replace type_PID = 2 if countryelection_FE == 108 & PID_who == 5280015

replace party_voted = 326 if countryelection_FE == 108 & IMD3002_LH_PL == 5280023 //* Communists
replace party_PID = 326 if countryelection_FE == 108 & PID_who == 5280023
replace type_voted = 6 if countryelection_FE == 108 & IMD3002_LH_PL == 5280023
replace type_PID = 6 if countryelection_FE == 108 & PID_who == 5280023

replace party_voted = 327 if countryelection_FE == 108 & IMD3002_LH_PL == 5280033 //* Pacifist Socialist Party
replace party_PID = 327 if countryelection_FE == 108 & PID_who == 5280033
replace type_voted = 6 if countryelection_FE == 108 & IMD3002_LH_PL == 5280033
replace type_PID = 6 if countryelection_FE == 108 & PID_who == 5280033

replace party_voted = 141 if countryelection_FE == 108 & IMD3002_LH_PL == 5280014 //* List Pim Fortuyn
replace party_PID = 141 if countryelection_FE == 108 & PID_who == 5280014
replace type_voted = 7 if countryelection_FE == 108 & IMD3002_LH_PL == 5280014
replace type_PID = 7 if countryelection_FE == 108 & PID_who == 5280014

replace party_voted = 143 if countryelection_FE == 108 & IMD3002_LH_PL == 5280016 //* Livable Netherlands
replace party_PID = 143 if countryelection_FE == 108 & PID_who == 5280016
replace type_voted = 7 if countryelection_FE == 108 & IMD3002_LH_PL == 5280016
replace type_PID = 7 if countryelection_FE == 108 & PID_who == 5280016

replace party_voted = 149 if countryelection_FE == 108 & IMD3002_LH_PL == 5280034 //* Party for the Future
replace party_PID = 149 if countryelection_FE == 108 & PID_who == 5280034
replace type_voted = 2 if countryelection_FE == 108 & IMD3002_LH_PL == 5280034
replace type_PID = 2 if countryelection_FE == 108 & PID_who == 5280034



//* Netherlands 2006

replace incumbent_voted = 1 if countryelection_FE == 109 & inlist(IMD3002_LH_PL,5280001,5280003)  //* 	CDA-VVD
replace incumbent_PID = 1 if countryelection_FE == 109 & inlist(PID_who,5280001,5280003)

replace party_voted = 129 if countryelection_FE == 109 & IMD3002_LH_PL == 5280001 //* CDA
replace party_PID = 129 if countryelection_FE == 109 & PID_who == 5280001
replace type_voted = 1 if countryelection_FE == 109 & IMD3002_LH_PL == 5280001
replace type_PID = 1 if countryelection_FE == 109 & PID_who == 5280001

replace party_voted = 130 if countryelection_FE == 109 & IMD3002_LH_PL == 5280002 //* Labour Party
replace party_PID = 130 if countryelection_FE == 109 & PID_who == 5280002
replace type_voted = 1 if countryelection_FE == 109 & IMD3002_LH_PL == 5280002
replace type_PID = 1 if countryelection_FE == 109 & PID_who == 5280002

replace party_voted = 131 if countryelection_FE == 109 & IMD3002_LH_PL == 5280003 //* People's Party for Freedom and Democracy
replace party_PID = 131 if countryelection_FE == 109 & PID_who == 5280003
replace type_voted = 1 if countryelection_FE == 109 & IMD3002_LH_PL == 5280003
replace type_PID = 1 if countryelection_FE == 109 & PID_who == 5280003

replace party_voted = 132 if countryelection_FE == 109 & IMD3002_LH_PL == 5280004 //* Democrats 66
replace party_PID = 132 if countryelection_FE == 109 & PID_who == 5280004
replace type_voted = 2 if countryelection_FE == 109 & IMD3002_LH_PL == 5280004
replace type_PID = 2 if countryelection_FE == 109 & PID_who == 5280004

replace party_voted = 133 if countryelection_FE == 109 & IMD3002_LH_PL == 5280005 //* GreenLeft
replace party_PID = 133 if countryelection_FE == 109 & PID_who == 5280005
replace type_voted = 2 if countryelection_FE == 109 & IMD3002_LH_PL == 5280005
replace type_PID = 2 if countryelection_FE == 109 & PID_who == 5280005

replace party_voted = 134 if countryelection_FE == 109 & IMD3002_LH_PL == 5280006 //* Socialist Party
replace party_PID = 134 if countryelection_FE == 109 & PID_who == 5280006
replace type_voted = 6 if countryelection_FE == 109 & IMD3002_LH_PL == 5280006
replace type_PID = 6 if countryelection_FE == 109 & PID_who == 5280006

replace party_voted = 135 if countryelection_FE == 109 & IMD3002_LH_PL == 5280007 //* Reformed Party
replace party_PID = 135 if countryelection_FE == 109 & PID_who == 5280007
replace type_voted = 7 if countryelection_FE == 109 & IMD3002_LH_PL == 5280007
replace type_PID = 7 if countryelection_FE == 109 & PID_who == 5280007

replace party_voted = 136 if countryelection_FE == 109 & IMD3002_LH_PL == 5280008 //* Christian Union
replace party_PID = 136 if countryelection_FE == 109 & PID_who == 5280008
replace type_voted = 3 if countryelection_FE == 109 & IMD3002_LH_PL == 5280008
replace type_PID = 3 if countryelection_FE == 109 & PID_who == 5280008

replace party_voted = 144 if countryelection_FE == 109 & IMD3002_LH_PL == 5280017 //* United Senior's Party
replace party_PID = 144 if countryelection_FE == 109 & PID_who == 5280017
replace type_voted = 3 if countryelection_FE == 109 & IMD3002_LH_PL == 5280017
replace type_PID = 3 if countryelection_FE == 109 & PID_who == 5280017

replace party_voted = 145 if countryelection_FE == 109 & IMD3002_LH_PL == 5280021 //* Centre Democrats
replace party_PID = 145 if countryelection_FE == 109 & PID_who == 5280021
replace type_voted = 7 if countryelection_FE == 109 & IMD3002_LH_PL == 5280021
replace type_PID = 7 if countryelection_FE == 109 & PID_who == 5280021

replace party_voted = 146 if countryelection_FE == 109 & IMD3002_LH_PL == 5280026 //* Reformed Political Alliance
replace party_PID = 146 if countryelection_FE == 109 & PID_who == 5280026
replace type_voted = 7 if countryelection_FE == 109 & IMD3002_LH_PL == 5280026
replace type_PID = 7 if countryelection_FE == 109 & PID_who == 5280026

replace party_voted = 147 if countryelection_FE == 109 & IMD3002_LH_PL == 5280027 //* Dutch Greens
replace party_PID = 147 if countryelection_FE == 109 & PID_who == 5280027
replace type_voted = 6 if countryelection_FE == 109 & IMD3002_LH_PL == 5280027
replace type_PID = 6 if countryelection_FE == 109 & PID_who == 5280027

replace party_voted = 148 if countryelection_FE == 109 & IMD3002_LH_PL == 5280030 //* Natural Law Party
replace party_PID = 148 if countryelection_FE == 109 & PID_who == 5280030
replace type_voted = 2 if countryelection_FE == 109 & IMD3002_LH_PL == 5280030
replace type_PID = 2 if countryelection_FE == 109 & PID_who == 5280030

replace party_voted = 150 if countryelection_FE == 109 & IMD3002_LH_PL == 5280035 //* Reformed Federation
replace party_PID = 150 if countryelection_FE == 109 & PID_who == 5280035
replace type_voted = 7 if countryelection_FE == 109 & IMD3002_LH_PL == 5280035
replace type_PID = 7 if countryelection_FE == 109 & PID_who == 5280035

replace party_voted = 151 if countryelection_FE == 109 & IMD3002_LH_PL == 5280038 //* Free Indian Party
replace party_PID = 151 if countryelection_FE == 109 & PID_who == 5280038
replace type_voted = 3 if countryelection_FE == 109 & IMD3002_LH_PL == 5280038
replace type_PID = 3 if countryelection_FE == 109 & PID_who == 5280038

replace party_voted = 152 if countryelection_FE == 109 & IMD3002_LH_PL == 5280040 //* Union 55+
replace party_PID = 152 if countryelection_FE == 109 & PID_who == 5280040 
replace type_voted = 3 if countryelection_FE == 109 & IMD3002_LH_PL == 5280040 
replace type_PID = 3 if countryelection_FE == 109 & PID_who == 5280040 

replace party_voted = 153 if countryelection_FE == 109 & IMD3002_LH_PL == 5280041 //* Seniors 2000
replace party_PID = 153 if countryelection_FE == 109 & PID_who == 5280041 
replace type_voted = 3 if countryelection_FE == 109 & IMD3002_LH_PL == 5280041 
replace type_PID = 3 if countryelection_FE == 109 & PID_who == 5280041 

replace party_voted = 154 if countryelection_FE == 109 & IMD3002_LH_PL == 5280042 //* Mobile Netherlands
replace party_PID = 154 if countryelection_FE == 109 & PID_who == 5280042
replace type_voted = 2 if countryelection_FE == 109 & IMD3002_LH_PL == 5280042
replace type_PID = 2 if countryelection_FE == 109 & PID_who == 5280042

replace party_voted = 142 if countryelection_FE == 109 & IMD3002_LH_PL == 5280015 //* Local List
replace party_PID = 142 if countryelection_FE == 109 & PID_who == 5280015
replace type_voted = 2 if countryelection_FE == 109 & IMD3002_LH_PL == 5280015
replace type_PID = 2 if countryelection_FE == 109 & PID_who == 5280015

replace party_voted = 326 if countryelection_FE == 109 & IMD3002_LH_PL == 5280023 //* Communists
replace party_PID = 326 if countryelection_FE == 109 & PID_who == 5280023
replace type_voted = 6 if countryelection_FE == 109 & IMD3002_LH_PL == 5280023
replace type_PID = 6 if countryelection_FE == 109 & PID_who == 5280023

replace party_voted = 327 if countryelection_FE == 109 & IMD3002_LH_PL == 5280033 //* Pacifist Socialist Party
replace party_PID = 327 if countryelection_FE == 109 & PID_who == 5280033
replace type_voted = 6 if countryelection_FE == 109 & IMD3002_LH_PL == 5280033
replace type_PID = 6 if countryelection_FE == 109 & PID_who == 5280033

replace party_voted = 141 if countryelection_FE == 109 & IMD3002_LH_PL == 5280014 //* List Pim Fortuyn
replace party_PID = 141 if countryelection_FE == 109 & PID_who == 5280014
replace type_voted = 5 if countryelection_FE == 109 & IMD3002_LH_PL == 5280014
replace type_PID = 5 if countryelection_FE == 109 & PID_who == 5280014

replace party_voted = 143 if countryelection_FE == 109 & IMD3002_LH_PL == 5280016 //* Livable Netherlands
replace party_PID = 143 if countryelection_FE == 109 & PID_who == 5280016
replace type_voted = 7 if countryelection_FE == 109 & IMD3002_LH_PL == 5280016
replace type_PID = 7 if countryelection_FE == 109 & PID_who == 5280016

replace party_voted = 149 if countryelection_FE == 109 & IMD3002_LH_PL == 5280034 //* Party for the Future
replace party_PID = 149 if countryelection_FE == 109 & PID_who == 5280034
replace type_voted = 2 if countryelection_FE == 109 & IMD3002_LH_PL == 5280034
replace type_PID = 2 if countryelection_FE == 109 & PID_who == 5280034

replace party_voted = 139 if countryelection_FE == 109 & IMD3002_LH_PL == 5280012 //* One Netherlands
replace party_PID = 139 if countryelection_FE == 109 & PID_who == 5280012
replace type_voted = 7 if countryelection_FE == 109 & IMD3002_LH_PL == 5280012
replace type_PID = 7 if countryelection_FE == 109 & PID_who == 5280012

replace party_voted = 140 if countryelection_FE == 109 & IMD3002_LH_PL == 5280013 //* Party for the Animals
replace party_PID = 140 if countryelection_FE == 109 & PID_who == 5280013
replace type_voted = 2 if countryelection_FE == 109 & IMD3002_LH_PL == 5280013
replace type_PID = 2 if countryelection_FE == 109 & PID_who == 5280013

replace party_voted = 137 if countryelection_FE == 109 & IMD3002_LH_PL == 5280009 //* Party for Freedom
replace party_PID = 137 if countryelection_FE == 109 & PID_who == 5280009
replace type_voted = 7 if countryelection_FE == 109 & IMD3002_LH_PL == 5280009
replace type_PID = 7 if countryelection_FE == 109 & PID_who == 5280009



//* Netherlands 2010

replace incumbent_voted = 1 if countryelection_FE == 110 & inlist(IMD3002_LH_PL,5280001,5280003)  //* 	CDA-VVD
replace incumbent_PID = 1 if countryelection_FE == 110 & inlist(PID_who,5280001,5280003)

replace party_voted = 129 if countryelection_FE == 110 & IMD3002_LH_PL == 5280001 //* CDA
replace party_PID = 129 if countryelection_FE == 110 & PID_who == 5280001
replace type_voted = 1 if countryelection_FE == 110 & IMD3002_LH_PL == 5280001
replace type_PID = 1 if countryelection_FE == 110 & PID_who == 5280001

replace party_voted = 130 if countryelection_FE == 110 & IMD3002_LH_PL == 5280002 //* Labour Party
replace party_PID = 130 if countryelection_FE == 110 & PID_who == 5280002
replace type_voted = 1 if countryelection_FE == 110 & IMD3002_LH_PL == 5280002
replace type_PID = 1 if countryelection_FE == 110 & PID_who == 5280002

replace party_voted = 131 if countryelection_FE == 110 & IMD3002_LH_PL == 5280003 //* People's Party for Freedom and Democracy
replace party_PID = 131 if countryelection_FE == 110 & PID_who == 5280003
replace type_voted = 1 if countryelection_FE == 110 & IMD3002_LH_PL == 5280003
replace type_PID = 1 if countryelection_FE == 110 & PID_who == 5280003

replace party_voted = 132 if countryelection_FE == 110 & IMD3002_LH_PL == 5280004 //* Democrats 66
replace party_PID = 132 if countryelection_FE == 110 & PID_who == 5280004
replace type_voted = 4 if countryelection_FE == 110 & IMD3002_LH_PL == 5280004
replace type_PID = 4 if countryelection_FE == 110 & PID_who == 5280004

replace party_voted = 133 if countryelection_FE == 110 & IMD3002_LH_PL == 5280005 //* GreenLeft
replace party_PID = 133 if countryelection_FE == 110 & PID_who == 5280005
replace type_voted = 2 if countryelection_FE == 110 & IMD3002_LH_PL == 5280005
replace type_PID = 2 if countryelection_FE == 110 & PID_who == 5280005

replace party_voted = 134 if countryelection_FE == 110 & IMD3002_LH_PL == 5280006 //* Socialist Party
replace party_PID = 134 if countryelection_FE == 110 & PID_who == 5280006
replace type_voted = 6 if countryelection_FE == 110 & IMD3002_LH_PL == 5280006
replace type_PID = 6 if countryelection_FE == 110 & PID_who == 5280006

replace party_voted = 135 if countryelection_FE == 110 & IMD3002_LH_PL == 5280007 //* Reformed Party
replace party_PID = 135 if countryelection_FE == 110 & PID_who == 5280007
replace type_voted = 7 if countryelection_FE == 110 & IMD3002_LH_PL == 5280007
replace type_PID = 7 if countryelection_FE == 110 & PID_who == 5280007

replace party_voted = 136 if countryelection_FE == 110 & IMD3002_LH_PL == 5280008 //* Christian Union
replace party_PID = 136 if countryelection_FE == 110 & PID_who == 5280008
replace type_voted = 1 if countryelection_FE == 110 & IMD3002_LH_PL == 5280008
replace type_PID = 1 if countryelection_FE == 110 & PID_who == 5280008

replace party_voted = 144 if countryelection_FE == 110 & IMD3002_LH_PL == 5280017 //* United Senior's Party
replace party_PID = 144 if countryelection_FE == 110 & PID_who == 5280017
replace type_voted = 3 if countryelection_FE == 110 & IMD3002_LH_PL == 5280017
replace type_PID = 3 if countryelection_FE == 110 & PID_who == 5280017

replace party_voted = 145 if countryelection_FE == 110 & IMD3002_LH_PL == 5280021 //* Centre Democrats
replace party_PID = 145 if countryelection_FE == 110 & PID_who == 5280021
replace type_voted = 7 if countryelection_FE == 110 & IMD3002_LH_PL == 5280021
replace type_PID = 7 if countryelection_FE == 110 & PID_who == 5280021

replace party_voted = 146 if countryelection_FE == 110 & IMD3002_LH_PL == 5280026 //* Reformed Political Alliance
replace party_PID = 146 if countryelection_FE == 110 & PID_who == 5280026
replace type_voted = 7 if countryelection_FE == 110 & IMD3002_LH_PL == 5280026
replace type_PID = 7 if countryelection_FE == 110 & PID_who == 5280026

replace party_voted = 147 if countryelection_FE == 110 & IMD3002_LH_PL == 5280027 //* Dutch Greens
replace party_PID = 147 if countryelection_FE == 110 & PID_who == 5280027
replace type_voted = 6 if countryelection_FE == 110 & IMD3002_LH_PL == 5280027
replace type_PID = 6 if countryelection_FE == 110 & PID_who == 5280027

replace party_voted = 148 if countryelection_FE == 110 & IMD3002_LH_PL == 5280030 //* Natural Law Party
replace party_PID = 148 if countryelection_FE == 110 & PID_who == 5280030
replace type_voted = 2 if countryelection_FE == 110 & IMD3002_LH_PL == 5280030
replace type_PID = 2 if countryelection_FE == 110 & PID_who == 5280030

replace party_voted = 150 if countryelection_FE == 110 & IMD3002_LH_PL == 5280035 //* Reformed Federation
replace party_PID = 150 if countryelection_FE == 110 & PID_who == 5280035
replace type_voted = 7 if countryelection_FE == 110 & IMD3002_LH_PL == 5280035
replace type_PID = 7 if countryelection_FE == 110 & PID_who == 5280035

replace party_voted = 151 if countryelection_FE == 110 & IMD3002_LH_PL == 5280038 //* Free Indian Party
replace party_PID = 151 if countryelection_FE == 110 & PID_who == 5280038
replace type_voted = 3 if countryelection_FE == 110 & IMD3002_LH_PL == 5280038
replace type_PID = 3 if countryelection_FE == 110 & PID_who == 5280038

replace party_voted = 152 if countryelection_FE == 110 & IMD3002_LH_PL == 5280040 //* Union 55+
replace party_PID = 152 if countryelection_FE == 110 & PID_who == 5280040 
replace type_voted = 3 if countryelection_FE == 110 & IMD3002_LH_PL == 5280040 
replace type_PID = 3 if countryelection_FE == 110 & PID_who == 5280040 

replace party_voted = 153 if countryelection_FE == 110 & IMD3002_LH_PL == 5280041 //* Seniors 2000
replace party_PID = 153 if countryelection_FE == 110 & PID_who == 5280041 
replace type_voted = 3 if countryelection_FE == 110 & IMD3002_LH_PL == 5280041 
replace type_PID = 3 if countryelection_FE == 110 & PID_who == 5280041 

replace party_voted = 154 if countryelection_FE == 110 & IMD3002_LH_PL == 5280042 //* Mobile Netherlands
replace party_PID = 154 if countryelection_FE == 110 & PID_who == 5280042
replace type_voted = 2 if countryelection_FE == 110 & IMD3002_LH_PL == 5280042
replace type_PID = 2 if countryelection_FE == 110 & PID_who == 5280042

replace party_voted = 142 if countryelection_FE == 110 & IMD3002_LH_PL == 5280015 //* Local List
replace party_PID = 142 if countryelection_FE == 110 & PID_who == 5280015
replace type_voted = 2 if countryelection_FE == 110 & IMD3002_LH_PL == 5280015
replace type_PID = 2 if countryelection_FE == 110 & PID_who == 5280015

replace party_voted = 326 if countryelection_FE == 110 & IMD3002_LH_PL == 5280023 //* Communists
replace party_PID = 326 if countryelection_FE == 110 & PID_who == 5280023
replace type_voted = 6 if countryelection_FE == 110 & IMD3002_LH_PL == 5280023
replace type_PID = 6 if countryelection_FE == 110 & PID_who == 5280023

replace party_voted = 327 if countryelection_FE == 110 & IMD3002_LH_PL == 5280033 //* Pacifist Socialist Party
replace party_PID = 327 if countryelection_FE == 110 & PID_who == 5280033
replace type_voted = 6 if countryelection_FE == 110 & IMD3002_LH_PL == 5280033
replace type_PID = 6 if countryelection_FE == 110 & PID_who == 5280033

replace party_voted = 141 if countryelection_FE == 110 & IMD3002_LH_PL == 5280014 //* List Pim Fortuyn
replace party_PID = 141 if countryelection_FE == 110 & PID_who == 5280014
replace type_voted = 5 if countryelection_FE == 110 & IMD3002_LH_PL == 5280014
replace type_PID = 5 if countryelection_FE == 110 & PID_who == 5280014

replace party_voted = 143 if countryelection_FE == 110 & IMD3002_LH_PL == 5280016 //* Livable Netherlands
replace party_PID = 143 if countryelection_FE == 110 & PID_who == 5280016
replace type_voted = 7 if countryelection_FE == 110 & IMD3002_LH_PL == 5280016
replace type_PID = 7 if countryelection_FE == 110 & PID_who == 5280016

replace party_voted = 149 if countryelection_FE == 110 & IMD3002_LH_PL == 5280034 //* Party for the Future
replace party_PID = 149 if countryelection_FE == 110 & PID_who == 5280034
replace type_voted = 2 if countryelection_FE == 110 & IMD3002_LH_PL == 5280034
replace type_PID = 2 if countryelection_FE == 110 & PID_who == 5280034

replace party_voted = 139 if countryelection_FE == 110 & IMD3002_LH_PL == 5280012 //* One Netherlands
replace party_PID = 139 if countryelection_FE == 110 & PID_who == 5280012
replace type_voted = 7 if countryelection_FE == 110 & IMD3002_LH_PL == 5280012
replace type_PID = 7 if countryelection_FE == 110 & PID_who == 5280012

replace party_voted = 140 if countryelection_FE == 110 & IMD3002_LH_PL == 5280013 //* Party for the Animals
replace party_PID = 140 if countryelection_FE == 110 & PID_who == 5280013
replace type_voted = 2 if countryelection_FE == 110 & IMD3002_LH_PL == 5280013
replace type_PID = 2 if countryelection_FE == 110 & PID_who == 5280013

replace party_voted = 137 if countryelection_FE == 110 & IMD3002_LH_PL == 5280009 //* Party for Freedom
replace party_PID = 137 if countryelection_FE == 110 & PID_who == 5280009
replace type_voted = 7 if countryelection_FE == 110 & IMD3002_LH_PL == 5280009
replace type_PID = 7 if countryelection_FE == 110 & PID_who == 5280009

replace party_voted = 138 if countryelection_FE == 110 & IMD3002_LH_PL == 5280011 //* Proud of the Netherlands
replace party_PID = 138 if countryelection_FE == 110 & PID_who == 5280011
replace type_voted = 7 if countryelection_FE == 110 & IMD3002_LH_PL == 5280011
replace type_PID = 7 if countryelection_FE == 110 & PID_who == 5280011

//* Norway 1997

replace incumbent_voted = 1 if countryelection_FE == 111 & IMD3002_LH_PL == 5780001  //* 	Labour
replace incumbent_PID = 1 if countryelection_FE == 111 & PID_who == 5780001

replace party_voted = 155 if countryelection_FE == 111 & IMD3002_LH_PL == 5780001 //* Labour
replace party_PID = 155 if countryelection_FE == 111 & PID_who == 5780001
replace type_voted = 1 if countryelection_FE == 111 & IMD3002_LH_PL == 5780001
replace type_PID = 1 if countryelection_FE == 111 & PID_who == 5780001

replace party_voted = 156 if countryelection_FE == 111 & IMD3002_LH_PL == 5780002 //* Conservative
replace party_PID = 156 if countryelection_FE == 111 & PID_who == 5780002
replace type_voted = 1 if countryelection_FE == 111 & IMD3002_LH_PL == 5780002
replace type_PID = 1 if countryelection_FE == 111 & PID_who == 5780002

replace party_voted = 157 if countryelection_FE == 111 & IMD3002_LH_PL == 5780003 //* Progress Party
replace party_PID = 157 if countryelection_FE == 111 & PID_who == 5780003
replace type_voted = 7 if countryelection_FE == 111 & IMD3002_LH_PL == 5780003
replace type_PID = 7 if countryelection_FE == 111 & PID_who == 5780003

replace party_voted = 158 if countryelection_FE == 111 & IMD3002_LH_PL == 5780004 //* Socialist Left
replace party_PID = 158 if countryelection_FE == 111 & PID_who == 5780004
replace type_voted = 6 if countryelection_FE == 111 & IMD3002_LH_PL == 5780004
replace type_PID = 6 if countryelection_FE == 111 & PID_who == 5780004

replace party_voted = 160 if countryelection_FE == 111 & IMD3002_LH_PL == 5780006 //* Centre Party
replace party_PID = 160 if countryelection_FE == 111 & PID_who == 5780006
replace type_voted = 1 if countryelection_FE == 111 & IMD3002_LH_PL == 5780006
replace type_PID = 1 if countryelection_FE == 111 & PID_who == 5780006

replace party_voted = 161 if countryelection_FE == 111 & IMD3002_LH_PL == 5780007 //* Christian People's Party
replace party_PID = 161 if countryelection_FE == 111 & PID_who == 5780007
replace type_voted = 1 if countryelection_FE == 111 & IMD3002_LH_PL == 5780007
replace type_PID = 1 if countryelection_FE == 111 & PID_who == 5780007

replace party_voted = 162 if countryelection_FE == 111 & IMD3002_LH_PL == 5780008 //* Liberal Party
replace party_PID = 162 if countryelection_FE == 111 & PID_who == 5780008
replace type_voted = 1 if countryelection_FE == 111 & IMD3002_LH_PL == 5780008
replace type_PID = 1 if countryelection_FE == 111 & PID_who == 5780008

replace party_voted = 163 if countryelection_FE == 111 & IMD3002_LH_PL == 5780010 | countryelection_FE == 111 & IMD3002_LH_PL == 5780009 //* Red Party
replace party_PID = 163 if countryelection_FE == 111 & PID_who == 5780010  | countryelection_FE == 111 & PID_who == 5780009
replace type_voted = 6 if countryelection_FE == 111 & IMD3002_LH_PL == 5780010  | countryelection_FE == 111 & IMD3002_LH_PL == 5780009
replace type_PID = 6 if countryelection_FE == 111 & PID_who == 5780010 | countryelection_FE == 111 & PID_who == 5780009


//* Norway 2001

replace incumbent_voted = 1 if countryelection_FE == 112 & IMD3002_LH_PL == 5780001  //* 	Labour
replace incumbent_PID = 1 if countryelection_FE == 112 & PID_who == 5780001

replace party_voted = 155 if countryelection_FE == 112 & IMD3002_LH_PL == 5780001 //* Labour
replace party_PID = 155 if countryelection_FE == 112 & PID_who == 5780001
replace type_voted = 1 if countryelection_FE == 112 & IMD3002_LH_PL == 5780001
replace type_PID = 1 if countryelection_FE == 112 & PID_who == 5780001

replace party_voted = 156 if countryelection_FE == 112 & IMD3002_LH_PL == 5780002 //* Conservative
replace party_PID = 156 if countryelection_FE == 112 & PID_who == 5780002
replace type_voted = 1 if countryelection_FE == 112 & IMD3002_LH_PL == 5780002
replace type_PID = 1 if countryelection_FE == 112 & PID_who == 5780002

replace party_voted = 157 if countryelection_FE == 112 & IMD3002_LH_PL == 5780003 //* Progress Party
replace party_PID = 157 if countryelection_FE == 112 & PID_who == 5780003
replace type_voted = 7 if countryelection_FE == 112 & IMD3002_LH_PL == 5780003
replace type_PID = 7 if countryelection_FE == 112 & PID_who == 5780003

replace party_voted = 158 if countryelection_FE == 112 & IMD3002_LH_PL == 5780004 //* Socialist Left
replace party_PID = 158 if countryelection_FE == 112 & PID_who == 5780004
replace type_voted = 2 if countryelection_FE == 112 & IMD3002_LH_PL == 5780004
replace type_PID = 2 if countryelection_FE == 112 & PID_who == 5780004

replace party_voted = 160 if countryelection_FE == 112 & IMD3002_LH_PL == 5780006 //* Centre Party
replace party_PID = 160 if countryelection_FE == 112 & PID_who == 5780006
replace type_voted = 1 if countryelection_FE == 112 & IMD3002_LH_PL == 5780006
replace type_PID = 1 if countryelection_FE == 112 & PID_who == 5780006

replace party_voted = 161 if countryelection_FE == 112 & IMD3002_LH_PL == 5780007 //* Christian People's Party
replace party_PID = 161 if countryelection_FE == 112 & PID_who == 5780007
replace type_voted = 1 if countryelection_FE == 112 & IMD3002_LH_PL == 5780007
replace type_PID = 1 if countryelection_FE == 112 & PID_who == 5780007

replace party_voted = 162 if countryelection_FE == 112 & IMD3002_LH_PL == 5780008 //* Liberal Party
replace party_PID = 162 if countryelection_FE == 112 & PID_who == 5780008
replace type_voted = 1 if countryelection_FE == 112 & IMD3002_LH_PL == 5780008
replace type_PID = 1 if countryelection_FE == 112 & PID_who == 5780008

replace party_voted = 163 if countryelection_FE == 112 & IMD3002_LH_PL == 5780010 | countryelection_FE == 112 & IMD3002_LH_PL == 5780009 //* Red Party
replace party_PID = 163 if countryelection_FE == 112 & PID_who == 5780010  | countryelection_FE == 112 & PID_who == 5780009
replace type_voted = 6 if countryelection_FE == 112 & IMD3002_LH_PL == 5780010  | countryelection_FE == 112 & IMD3002_LH_PL == 5780009
replace type_PID = 6 if countryelection_FE == 112 & PID_who == 5780010 | countryelection_FE == 112 & PID_who == 5780009

replace party_voted = 159 if countryelection_FE == 112 & IMD3002_LH_PL ==  5780005 //* Greens
replace party_PID = 159 if countryelection_FE == 112 & PID_who ==  5780005 
replace type_voted = 6 if countryelection_FE == 112 & IMD3002_LH_PL ==  5780005
replace type_PID = 6 if countryelection_FE == 112 & PID_who == 5780005 



//* Norway 2005

replace incumbent_voted = 1 if countryelection_FE == 113 & inlist(IMD3002_LH_PL,5780007,5780002,5780008)  //* 	ChristDem-Cons-Liberal
replace incumbent_PID = 1 if countryelection_FE == 113 & inlist(PID_who,5780007,5780002,5780008)

replace party_voted = 155 if countryelection_FE == 113 & IMD3002_LH_PL == 5780001 //* Labour
replace party_PID = 155 if countryelection_FE == 113 & PID_who == 5780001
replace type_voted = 1 if countryelection_FE == 113 & IMD3002_LH_PL == 5780001
replace type_PID = 1 if countryelection_FE == 113 & PID_who == 5780001

replace party_voted = 156 if countryelection_FE == 113 & IMD3002_LH_PL == 5780002 //* Conservative
replace party_PID = 156 if countryelection_FE == 113 & PID_who == 5780002
replace type_voted = 1 if countryelection_FE == 113 & IMD3002_LH_PL == 5780002
replace type_PID = 1 if countryelection_FE == 113 & PID_who == 5780002

replace party_voted = 157 if countryelection_FE == 113 & IMD3002_LH_PL == 5780003 //* Progress Party
replace party_PID = 157 if countryelection_FE == 113 & PID_who == 5780003
replace type_voted = 5 if countryelection_FE == 113 & IMD3002_LH_PL == 5780003
replace type_PID = 5 if countryelection_FE == 113 & PID_who == 5780003

replace party_voted = 158 if countryelection_FE == 113 & IMD3002_LH_PL == 5780004 //* Socialist Left
replace party_PID = 158 if countryelection_FE == 113 & PID_who == 5780004
replace type_voted = 2 if countryelection_FE == 113 & IMD3002_LH_PL == 5780004
replace type_PID = 2 if countryelection_FE == 113 & PID_who == 5780004

replace party_voted = 160 if countryelection_FE == 113 & IMD3002_LH_PL == 5780006 //* Centre Party
replace party_PID = 160 if countryelection_FE == 113 & PID_who == 5780006
replace type_voted = 1 if countryelection_FE == 113 & IMD3002_LH_PL == 5780006
replace type_PID = 1 if countryelection_FE == 113 & PID_who == 5780006

replace party_voted = 161 if countryelection_FE == 113 & IMD3002_LH_PL == 5780007 //* Christian People's Party
replace party_PID = 161 if countryelection_FE == 113 & PID_who == 5780007
replace type_voted = 1 if countryelection_FE == 113 & IMD3002_LH_PL == 5780007
replace type_PID = 1 if countryelection_FE == 113 & PID_who == 5780007

replace party_voted = 162 if countryelection_FE == 113 & IMD3002_LH_PL == 5780008 //* Liberal Party
replace party_PID = 162 if countryelection_FE == 113 & PID_who == 5780008
replace type_voted = 1 if countryelection_FE == 113 & IMD3002_LH_PL == 5780008
replace type_PID = 1 if countryelection_FE == 113 & PID_who == 5780008

replace party_voted = 163 if countryelection_FE == 113 & IMD3002_LH_PL == 5780010 | countryelection_FE == 113 & IMD3002_LH_PL == 5780009 //* Red Party
replace party_PID = 163 if countryelection_FE == 113 & PID_who == 5780010  | countryelection_FE == 113 & PID_who == 5780009
replace type_voted = 6 if countryelection_FE == 113 & IMD3002_LH_PL == 5780010  | countryelection_FE == 113 & IMD3002_LH_PL == 5780009
replace type_PID = 6 if countryelection_FE == 113 & PID_who == 5780010 | countryelection_FE == 113 & PID_who == 5780009

replace party_voted = 159 if countryelection_FE == 113 & IMD3002_LH_PL ==  5780005 //* Green Party
replace party_PID = 159 if countryelection_FE == 113 & PID_who ==  5780005 
replace type_voted = 6 if countryelection_FE == 113 & IMD3002_LH_PL ==  5780005
replace type_PID = 6 if countryelection_FE == 113 & PID_who == 5780005 


//* Norway 2009

replace incumbent_voted = 1 if countryelection_FE == 114 & inlist(IMD3002_LH_PL,5780001,5780004,5780006)  //* 	Labour,SocLeft,Centre
replace incumbent_PID = 1 if countryelection_FE == 114 & inlist(PID_who,5780001,5780004,5780006)

replace party_voted = 155 if countryelection_FE == 114 & IMD3002_LH_PL == 5780001 //* Labour
replace party_PID = 155 if countryelection_FE == 114 & PID_who == 5780001
replace type_voted = 1 if countryelection_FE == 114 & IMD3002_LH_PL == 5780001
replace type_PID = 1 if countryelection_FE == 114 & PID_who == 5780001

replace party_voted = 156 if countryelection_FE == 114 & IMD3002_LH_PL == 5780002 //* Conservative
replace party_PID = 156 if countryelection_FE == 114 & PID_who == 5780002
replace type_voted = 1 if countryelection_FE == 114 & IMD3002_LH_PL == 5780002
replace type_PID = 1 if countryelection_FE == 114 & PID_who == 5780002

replace party_voted = 157 if countryelection_FE == 114 & IMD3002_LH_PL == 5780003 //* Progress Party
replace party_PID = 157 if countryelection_FE == 114 & PID_who == 5780003
replace type_voted = 1 if countryelection_FE == 114 & IMD3002_LH_PL == 5780003
replace type_PID = 1 if countryelection_FE == 114 & PID_who == 5780003

replace party_voted = 158 if countryelection_FE == 114 & IMD3002_LH_PL == 5780004 //* Socialist Left
replace party_PID = 158 if countryelection_FE == 114 & PID_who == 5780004
replace type_voted = 1 if countryelection_FE == 114 & IMD3002_LH_PL == 5780004
replace type_PID = 1 if countryelection_FE == 114 & PID_who == 5780004

replace party_voted = 160 if countryelection_FE == 114 & IMD3002_LH_PL == 5780006 //* Centre Party
replace party_PID = 160 if countryelection_FE == 114 & PID_who == 5780006
replace type_voted = 1 if countryelection_FE == 114 & IMD3002_LH_PL == 5780006
replace type_PID = 1 if countryelection_FE == 114 & PID_who == 5780006

replace party_voted = 161 if countryelection_FE == 114 & IMD3002_LH_PL == 5780007 //* Christian People's Party
replace party_PID = 161 if countryelection_FE == 114 & PID_who == 5780007
replace type_voted = 1 if countryelection_FE == 114 & IMD3002_LH_PL == 5780007
replace type_PID = 1 if countryelection_FE == 114 & PID_who == 5780007

replace party_voted = 162 if countryelection_FE == 114 & IMD3002_LH_PL == 5780008 //* Liberal Party
replace party_PID = 162 if countryelection_FE == 114 & PID_who == 5780008
replace type_voted = 1 if countryelection_FE == 114 & IMD3002_LH_PL == 5780008
replace type_PID = 1 if countryelection_FE == 114 & PID_who == 5780008

replace party_voted = 163 if countryelection_FE == 114 & IMD3002_LH_PL == 5780010 | countryelection_FE == 114 & IMD3002_LH_PL == 5780009 //* Red Party
replace party_PID = 163 if countryelection_FE == 114 & PID_who == 5780010  | countryelection_FE == 114 & PID_who == 5780009
replace type_voted = 6 if countryelection_FE == 114 & IMD3002_LH_PL == 5780010  | countryelection_FE == 114 & IMD3002_LH_PL == 5780009
replace type_PID = 6 if countryelection_FE == 114 & PID_who == 5780010 | countryelection_FE == 114 & PID_who == 5780009

replace party_voted = 159 if countryelection_FE == 114 & IMD3002_LH_PL ==  5780005 //* Green Party
replace party_PID = 159 if countryelection_FE == 114 & PID_who ==  5780005 
replace type_voted = 6 if countryelection_FE == 114 & IMD3002_LH_PL ==  5780005
replace type_PID = 6 if countryelection_FE == 114 & PID_who == 5780005 


//* Norway 2013

replace incumbent_voted = 1 if countryelection_FE == 115 & inlist(IMD3002_LH_PL,5780001,5780004,5780006)  //* 	Labour,SocLeft,Centre
replace incumbent_PID = 1 if countryelection_FE == 115 & inlist(PID_who,5780001,5780004,5780006)

replace party_voted = 155 if countryelection_FE == 115 & IMD3002_LH_PL == 5780001 //* Labour
replace party_PID = 155 if countryelection_FE == 115 & PID_who == 5780001
replace type_voted = 1 if countryelection_FE == 115 & IMD3002_LH_PL == 5780001
replace type_PID = 1 if countryelection_FE == 115 & PID_who == 5780001

replace party_voted = 156 if countryelection_FE == 115 & IMD3002_LH_PL == 5780002 //* Conservative
replace party_PID = 156 if countryelection_FE == 115 & PID_who == 5780002
replace type_voted = 1 if countryelection_FE == 115 & IMD3002_LH_PL == 5780002
replace type_PID = 1 if countryelection_FE == 115 & PID_who == 5780002

replace party_voted = 157 if countryelection_FE == 115 & IMD3002_LH_PL == 5780003 //* Progress Party
replace party_PID = 157 if countryelection_FE == 115 & PID_who == 5780003
replace type_voted = 1 if countryelection_FE == 115 & IMD3002_LH_PL == 5780003
replace type_PID = 1 if countryelection_FE == 115 & PID_who == 5780003

replace party_voted = 158 if countryelection_FE == 115 & IMD3002_LH_PL == 5780004 //* Socialist Left
replace party_PID = 158 if countryelection_FE == 115 & PID_who == 5780004
replace type_voted = 1 if countryelection_FE == 115 & IMD3002_LH_PL == 5780004
replace type_PID = 1 if countryelection_FE == 115 & PID_who == 5780004

replace party_voted = 160 if countryelection_FE == 115 & IMD3002_LH_PL == 5780006 //* Centre Party
replace party_PID = 160 if countryelection_FE == 115 & PID_who == 5780006
replace type_voted = 1 if countryelection_FE == 115 & IMD3002_LH_PL == 5780006
replace type_PID = 1 if countryelection_FE == 115 & PID_who == 5780006

replace party_voted = 161 if countryelection_FE == 115 & IMD3002_LH_PL == 5780007 //* Christian People's Party
replace party_PID = 161 if countryelection_FE == 115 & PID_who == 5780007
replace type_voted = 1 if countryelection_FE == 115 & IMD3002_LH_PL == 5780007
replace type_PID = 1 if countryelection_FE == 115 & PID_who == 5780007

replace party_voted = 162 if countryelection_FE == 115 & IMD3002_LH_PL == 5780008 //* Liberal Party
replace party_PID = 162 if countryelection_FE == 115 & PID_who == 5780008
replace type_voted = 1 if countryelection_FE == 115 & IMD3002_LH_PL == 5780008
replace type_PID = 1 if countryelection_FE == 115 & PID_who == 5780008

replace party_voted = 163 if countryelection_FE == 115 & IMD3002_LH_PL == 5780010 | countryelection_FE == 115 & IMD3002_LH_PL == 5780009 //* Red Party
replace party_PID = 163 if countryelection_FE == 115 & PID_who == 5780010  | countryelection_FE == 115 & PID_who == 5780009
replace type_voted = 6 if countryelection_FE == 115 & IMD3002_LH_PL == 5780010  | countryelection_FE == 115 & IMD3002_LH_PL == 5780009
replace type_PID = 6 if countryelection_FE == 115 & PID_who == 5780010 | countryelection_FE == 115 & PID_who == 5780009

replace party_voted = 159 if countryelection_FE == 115 & IMD3002_LH_PL ==  5780005 //* Green Party
replace party_PID = 159 if countryelection_FE == 115 & PID_who ==  5780005 
replace type_voted = 6 if countryelection_FE == 115 & IMD3002_LH_PL ==  5780005
replace type_PID = 6 if countryelection_FE == 115 & PID_who == 5780005 



//* New Zealand 1996

replace incumbent_voted = 1 if countryelection_FE == 116 & inlist(IMD3002_LH_DC,5540001,5540015, 5540037)  //* 	National, United NZ, Christians
replace incumbent_PID = 1 if countryelection_FE == 116 & inlist(PID_who,5540001,5540015, 5540037)

replace party_voted = 269 if countryelection_FE == 116 & IMD3002_LH_DC == 5540001 //* National
replace party_PID = 269 if countryelection_FE == 116 & PID_who == 5540001
replace type_voted = 1 if countryelection_FE == 116 & IMD3002_LH_DC == 5540001
replace type_PID = 1 if countryelection_FE == 116 & PID_who == 5540001

replace party_voted = 270 if countryelection_FE == 116 & IMD3002_LH_DC == 5540002 //* Labour
replace party_PID = 270 if countryelection_FE == 116 & PID_who == 5540002
replace type_voted = 1 if countryelection_FE == 116 & IMD3002_LH_DC == 5540002
replace type_PID = 1 if countryelection_FE == 116 & PID_who == 5540002

replace party_voted = 271 if countryelection_FE == 116 & IMD3002_LH_DC == 5540003 //* NZ First
replace party_PID = 271 if countryelection_FE == 116 & PID_who == 5540003
replace type_voted = 7 if countryelection_FE == 116 & IMD3002_LH_DC == 5540003
replace type_PID = 7 if countryelection_FE == 116 & PID_who == 5540003

replace party_voted = 272 if countryelection_FE == 116 & IMD3002_LH_DC == 5540004 //* ACT
replace party_PID = 272 if countryelection_FE == 116 & PID_who == 5540004
replace type_voted = 7 if countryelection_FE == 116 & IMD3002_LH_DC == 5540004
replace type_PID = 7 if countryelection_FE == 116 & PID_who == 5540004

replace party_voted = 277 if countryelection_FE == 116 & IMD3002_LH_DC == 5540009 //* Alliance
replace party_PID = 277 if countryelection_FE == 116 & PID_who == 5540009
replace type_voted = 2 if countryelection_FE == 116 & IMD3002_LH_DC == 5540009
replace type_PID = 2 if countryelection_FE == 116 & PID_who == 5540009

replace party_voted = 286 if countryelection_FE == 116 & IMD3002_LH_DC == 5540021 //* Progressive Greens
replace party_PID = 286 if countryelection_FE == 116 & PID_who == 5540021
replace type_voted = 2 if countryelection_FE == 116 & IMD3002_LH_DC == 5540021
replace type_PID = 2 if countryelection_FE == 116 & PID_who == 5540021

replace party_voted = 288 if countryelection_FE == 116 & IMD3002_LH_DC == 5540023 //* Mana Maori
replace party_PID = 288 if countryelection_FE == 116 & PID_who == 5540023
replace type_voted = 1 if countryelection_FE == 116 & IMD3002_LH_DC == 5540023
replace type_PID = 1 if countryelection_FE == 116 & PID_who == 5540023

replace party_voted = 294 if countryelection_FE == 116 & IMD3002_LH_DC == 5540034 //* McGillicuddy Serious
replace party_PID = 294 if countryelection_FE == 116 & PID_who == 5540034
replace type_voted = 2 if countryelection_FE == 116 & IMD3002_LH_DC == 5540034
replace type_PID = 2 if countryelection_FE == 116 & PID_who == 5540034

replace party_voted = 297 if countryelection_FE == 116 & IMD3002_LH_DC == 5540037 //* Christian Coalition
replace party_PID = 297 if countryelection_FE == 116 & PID_who == 5540037
replace type_voted = 1 if countryelection_FE == 116 & IMD3002_LH_DC == 5540037
replace type_PID = 1 if countryelection_FE == 116 & PID_who == 5540037

replace party_voted = 298 if countryelection_FE == 116 & IMD3002_LH_DC == 5540038 //* Legalise Cannabis
replace party_PID = 298 if countryelection_FE == 116 & PID_who == 5540038
replace type_voted = 2 if countryelection_FE == 116 & IMD3002_LH_DC == 5540038
replace type_PID = 2 if countryelection_FE == 116 & PID_who == 5540038

replace party_voted = 282 if countryelection_FE == 116 & IMD3002_LH_DC ==  5540015 //* United NZ
replace party_PID = 282 if countryelection_FE == 116 & PID_who ==  5540015
replace type_voted = 1 if countryelection_FE == 116 & IMD3002_LH_DC ==  5540015
replace type_PID = 1 if countryelection_FE == 116 & PID_who ==  5540015

//* New Zealand 2002

replace incumbent_voted = 1 if countryelection_FE == 117 & inlist(IMD3002_LH_DC,5540002, 5540009)  //* 	Labour, Alliance
replace incumbent_PID = 1 if countryelection_FE == 117 & inlist(PID_who,5540002, 5540009)

replace party_voted = 269 if countryelection_FE == 117 & IMD3002_LH_DC == 5540001 //* National
replace party_PID = 269 if countryelection_FE == 117 & PID_who == 5540001
replace type_voted = 1 if countryelection_FE == 117 & IMD3002_LH_DC == 5540001
replace type_PID = 1 if countryelection_FE == 117 & PID_who == 5540001

replace party_voted = 270 if countryelection_FE == 117 & IMD3002_LH_DC == 5540002 //* Labour
replace party_PID = 270 if countryelection_FE == 117 & PID_who == 5540002
replace type_voted = 1 if countryelection_FE == 117 & IMD3002_LH_DC == 5540002
replace type_PID = 1 if countryelection_FE == 117 & PID_who == 5540002

replace party_voted = 271 if countryelection_FE == 117 & IMD3002_LH_DC == 5540003 //* NZ First
replace party_PID = 271 if countryelection_FE == 117 & PID_who == 5540003
replace type_voted = 5 if countryelection_FE == 117 & IMD3002_LH_DC == 5540003
replace type_PID = 5 if countryelection_FE == 117 & PID_who == 5540003

replace party_voted = 272 if countryelection_FE == 117 & IMD3002_LH_DC == 5540004 //* ACT
replace party_PID = 272 if countryelection_FE == 117 & PID_who == 5540004
replace type_voted = 7 if countryelection_FE == 117 & IMD3002_LH_DC == 5540004
replace type_PID = 7 if countryelection_FE == 117 & PID_who == 5540004

replace party_voted = 273 if countryelection_FE == 117 & IMD3002_LH_DC == 5540005 //* Greens
replace party_PID = 273 if countryelection_FE == 117 & PID_who == 5540005
replace type_voted = 1 if countryelection_FE == 117 & IMD3002_LH_DC == 5540005
replace type_PID = 1 if countryelection_FE == 117 & PID_who == 5540005

replace party_voted = 274 if countryelection_FE == 117 & IMD3002_LH_DC == 5540006 //* NZ Future
replace party_PID = 274 if countryelection_FE == 117 & PID_who == 5540006
replace type_voted = 2 if countryelection_FE == 117 & IMD3002_LH_DC == 5540006
replace type_PID = 2 if countryelection_FE == 117 & PID_who == 5540006

replace party_voted = 277 if countryelection_FE == 117 & IMD3002_LH_DC == 5540009 //* Alliance
replace party_PID = 277 if countryelection_FE == 117 & PID_who == 5540009
replace type_voted = 1 if countryelection_FE == 117 & IMD3002_LH_DC == 5540009
replace type_PID = 1 if countryelection_FE == 117 & PID_who == 5540009

replace party_voted = 280 if countryelection_FE == 117 & IMD3002_LH_DC == 5540012 //* Anderton Progressives
replace party_PID = 280 if countryelection_FE == 117 & PID_who == 5540012
replace type_voted = 1 if countryelection_FE == 117 & IMD3002_LH_DC == 5540012
replace type_PID = 1 if countryelection_FE == 117 & PID_who == 5540012

replace party_voted = 328 if countryelection_FE == 117 & IMD3002_LH_DC == 5540013 //* Future NZ
replace party_PID = 328 if countryelection_FE == 117 & PID_who == 5540013
replace type_voted = 2 if countryelection_FE == 117 & IMD3002_LH_DC == 5540013
replace type_PID = 2 if countryelection_FE == 117 & PID_who == 5540013

replace party_voted = 281 if countryelection_FE == 117 & IMD3002_LH_DC == 5540014 //* Christian Heritage
replace party_PID = 281 if countryelection_FE == 117 & PID_who == 5540014
replace type_voted = 3 if countryelection_FE == 117 & IMD3002_LH_DC == 5540014
replace type_PID = 3 if countryelection_FE == 117 & PID_who == 5540014

replace party_voted = 276 if countryelection_FE == 117 & IMD3002_LH_DC == 5540024 //* Mana Motuhake
replace party_PID = 276 if countryelection_FE == 117 & PID_who == 5540024
replace type_voted = 1 if countryelection_FE == 117 & IMD3002_LH_DC == 5540024
replace type_PID = 1 if countryelection_FE == 117 & PID_who == 5540024

replace party_voted = 285 if countryelection_FE == 117 & IMD3002_LH_DC == 5540025 //* Libertarians
replace party_PID = 285 if countryelection_FE == 117 & PID_who == 5540025
replace type_voted = 7 if countryelection_FE == 117 & IMD3002_LH_DC == 5540025
replace type_PID = 7 if countryelection_FE == 117 & PID_who == 5540025

replace party_voted = 286 if countryelection_FE == 117 & IMD3002_LH_DC == 5540021 //* Progressive Greens
replace party_PID = 286 if countryelection_FE == 117 & PID_who == 5540021
replace type_voted = 2 if countryelection_FE == 117 & IMD3002_LH_DC == 5540021
replace type_PID = 2 if countryelection_FE == 117 & PID_who == 5540021

replace party_voted = 288 if countryelection_FE == 117 & IMD3002_LH_DC == 5540023 //* Mana Maori
replace party_PID = 288 if countryelection_FE == 117 & PID_who == 5540023
replace type_voted = 1 if countryelection_FE == 117 & IMD3002_LH_DC == 5540023
replace type_PID = 1 if countryelection_FE == 117 & PID_who == 5540023

replace party_voted = 329 if countryelection_FE == 117 & IMD3002_LH_DC == 5540028 //* NZ Democrats
replace party_PID = 329 if countryelection_FE == 117 & PID_who == 5540028
replace type_voted = 7 if countryelection_FE == 117 & IMD3002_LH_DC == 5540028
replace type_PID = 7 if countryelection_FE == 117 & PID_who == 5540028

replace party_voted = 294 if countryelection_FE == 117 & IMD3002_LH_DC == 5540034 //* McGillicuddy Serious
replace party_PID = 294 if countryelection_FE == 117 & PID_who == 5540034
replace type_voted = 2 if countryelection_FE == 117 & IMD3002_LH_DC == 5540034
replace type_PID = 2 if countryelection_FE == 117 & PID_who == 5540034

replace party_voted = 297 if countryelection_FE == 117 & IMD3002_LH_DC == 5540037 //* Christian Coalition
replace party_PID = 297 if countryelection_FE == 117 & PID_who == 5540037
replace type_voted = 1 if countryelection_FE == 117 & IMD3002_LH_DC == 5540037
replace type_PID = 1 if countryelection_FE == 117 & PID_who == 5540037

replace party_voted = 298 if countryelection_FE == 117 & IMD3002_LH_DC == 5540038 //* Legalise Cannabis
replace party_PID = 298 if countryelection_FE == 117 & PID_who == 5540038
replace type_voted = 2 if countryelection_FE == 117 & IMD3002_LH_DC == 5540038
replace type_PID = 2 if countryelection_FE == 117 & PID_who == 5540038

replace party_voted = 296 if countryelection_FE == 117 & IMD3002_LH_DC == 5540036 //* Outdoor Recreation
replace party_PID = 296 if countryelection_FE == 117 & PID_who == 5540036
replace type_voted = 3 if countryelection_FE == 117 & IMD3002_LH_DC == 5540036
replace type_PID = 3 if countryelection_FE == 117 & PID_who == 5540036

replace party_voted = 282 if countryelection_FE == 117 & IMD3002_LH_DC ==  5540015 //* United NZ
replace party_PID = 282 if countryelection_FE == 117 & PID_who ==  5540015
replace type_voted = 1 if countryelection_FE == 117 & IMD3002_LH_DC ==  5540015
replace type_PID = 1 if countryelection_FE == 117 & PID_who ==  5540015

//* New Zealand 2008

replace incumbent_voted = 1 if countryelection_FE == 118 & inlist(IMD3002_LH_DC,5540002, 5540012)  //* 	Labour, Progressives
replace incumbent_PID = 1 if countryelection_FE == 118 & inlist(PID_who,5540002, 5540012)

replace party_voted = 269 if countryelection_FE == 118 & IMD3002_LH_DC == 5540001 //* National
replace party_PID = 269 if countryelection_FE == 118 & PID_who == 5540001
replace type_voted = 1 if countryelection_FE == 118 & IMD3002_LH_DC == 5540001
replace type_PID = 1 if countryelection_FE == 118 & PID_who == 5540001

replace party_voted = 270 if countryelection_FE == 118 & IMD3002_LH_DC == 5540002 //* Labour
replace party_PID = 270 if countryelection_FE == 118 & PID_who == 5540002
replace type_voted = 1 if countryelection_FE == 118 & IMD3002_LH_DC == 5540002
replace type_PID = 1 if countryelection_FE == 118 & PID_who == 5540002

replace party_voted = 271 if countryelection_FE == 118 & IMD3002_LH_DC == 5540003 //* NZ First
replace party_PID = 271 if countryelection_FE == 118 & PID_who == 5540003
replace type_voted = 5 if countryelection_FE == 118 & IMD3002_LH_DC == 5540003
replace type_PID = 5 if countryelection_FE == 118 & PID_who == 5540003

replace party_voted = 272 if countryelection_FE == 118 & IMD3002_LH_DC == 5540004 //* ACT
replace party_PID = 272 if countryelection_FE == 118 & PID_who == 5540004
replace type_voted = 7 if countryelection_FE == 118 & IMD3002_LH_DC == 5540004
replace type_PID = 7 if countryelection_FE == 118 & PID_who == 5540004

replace party_voted = 273 if countryelection_FE == 118 & IMD3002_LH_DC == 5540005 //* Greens
replace party_PID = 273 if countryelection_FE == 118 & PID_who == 5540005
replace type_voted = 1 if countryelection_FE == 118 & IMD3002_LH_DC == 5540005
replace type_PID = 1 if countryelection_FE == 118 & PID_who == 5540005

replace party_voted = 274 if countryelection_FE == 118 & IMD3002_LH_DC == 5540006 //* NZ Future
replace party_PID = 274 if countryelection_FE == 118 & PID_who == 5540006
replace type_voted = 1 if countryelection_FE == 118 & IMD3002_LH_DC == 5540006
replace type_PID = 1 if countryelection_FE == 118 & PID_who == 5540006

replace party_voted = 277 if countryelection_FE == 118 & IMD3002_LH_DC == 5540009 //* Alliance
replace party_PID = 277 if countryelection_FE == 118 & PID_who == 5540009
replace type_voted = 1 if countryelection_FE == 118 & IMD3002_LH_DC == 5540009
replace type_PID = 1 if countryelection_FE == 118 & PID_who == 5540009

replace party_voted = 280 if countryelection_FE == 118 & IMD3002_LH_DC == 5540012 //* Anderton Progressives
replace party_PID = 280 if countryelection_FE == 118 & PID_who == 5540012
replace type_voted = 1 if countryelection_FE == 118 & IMD3002_LH_DC == 5540012
replace type_PID = 1 if countryelection_FE == 118 & PID_who == 5540012

replace party_voted = 328 if countryelection_FE == 118 & IMD3002_LH_DC == 5540013 //* Future NZ
replace party_PID = 328 if countryelection_FE == 118 & PID_who == 5540013
replace type_voted = 1 if countryelection_FE == 118 & IMD3002_LH_DC == 5540013
replace type_PID = 1 if countryelection_FE == 118 & PID_who == 5540013

replace party_voted = 281 if countryelection_FE == 118 & IMD3002_LH_DC == 5540014 //* Christian Heritage
replace party_PID = 281 if countryelection_FE == 118 & PID_who == 5540014
replace type_voted = 3 if countryelection_FE == 118 & IMD3002_LH_DC == 5540014
replace type_PID = 3 if countryelection_FE == 118 & PID_who == 5540014

replace party_voted = 276 if countryelection_FE == 118 & IMD3002_LH_DC == 5540024 | countryelection_FE == 118 & IMD3002_LH_DC == 5540008 //* Mana Motuhake
replace party_PID = 276 if countryelection_FE == 118 & PID_who == 5540024 |  countryelection_FE == 118 & PID_who == 5540008
replace type_voted = 1 if countryelection_FE == 118 & IMD3002_LH_DC == 5540024 |  countryelection_FE == 118 & IMD3002_LH_DC == 5540008
replace type_PID = 1 if countryelection_FE == 118 & PID_who == 5540024 | countryelection_FE == 118 & PID_who == 5540008

replace party_voted = 285 if countryelection_FE == 118 & IMD3002_LH_DC == 5540025 //* Libertarians
replace party_PID = 285 if countryelection_FE == 118 & PID_who == 5540025
replace type_voted = 7 if countryelection_FE == 118 & IMD3002_LH_DC == 5540025
replace type_PID = 7 if countryelection_FE == 118 & PID_who == 5540025

replace party_voted = 286 if countryelection_FE == 118 & IMD3002_LH_DC == 5540021 //* Progressive Greens
replace party_PID = 286 if countryelection_FE == 118 & PID_who == 5540021
replace type_voted = 2 if countryelection_FE == 118 & IMD3002_LH_DC == 5540021
replace type_PID = 2 if countryelection_FE == 118 & PID_who == 5540021

replace party_voted = 288 if countryelection_FE == 118 & IMD3002_LH_DC == 5540023 //* Mana Maori
replace party_PID = 288 if countryelection_FE == 118 & PID_who == 5540023
replace type_voted = 1 if countryelection_FE == 118 & IMD3002_LH_DC == 5540023
replace type_PID = 1 if countryelection_FE == 118 & PID_who == 5540023

replace party_voted = 329 if countryelection_FE == 118 & IMD3002_LH_DC == 5540028 //* NZ Democrats
replace party_PID = 329 if countryelection_FE == 118 & PID_who == 5540028
replace type_voted = 6 if countryelection_FE == 118 & IMD3002_LH_DC == 5540028
replace type_PID = 6 if countryelection_FE == 118 & PID_who == 5540028

replace party_voted = 294 if countryelection_FE == 118 & IMD3002_LH_DC == 5540034 //* McGillicuddy Serious
replace party_PID = 294 if countryelection_FE == 118 & PID_who == 5540034
replace type_voted = 2 if countryelection_FE == 118 & IMD3002_LH_DC == 5540034
replace type_PID = 2 if countryelection_FE == 118 & PID_who == 5540034

replace party_voted = 297 if countryelection_FE == 118 & IMD3002_LH_DC == 5540037 //* Christian Coalition
replace party_PID = 297 if countryelection_FE == 118 & PID_who == 5540037
replace type_voted = 1 if countryelection_FE == 118 & IMD3002_LH_DC == 5540037
replace type_PID = 1 if countryelection_FE == 118 & PID_who == 5540037

replace party_voted = 298 if countryelection_FE == 118 & IMD3002_LH_DC == 5540038 //* Legalise Cannabis
replace party_PID = 298 if countryelection_FE == 118 & PID_who == 5540038
replace type_voted = 2 if countryelection_FE == 118 & IMD3002_LH_DC == 5540038
replace type_PID = 2 if countryelection_FE == 118 & PID_who == 5540038

replace party_voted = 296 if countryelection_FE == 118 & IMD3002_LH_DC == 5540036 //* Outdoor Recreation
replace party_PID = 296 if countryelection_FE == 118 & PID_who == 5540036
replace type_voted = 3 if countryelection_FE == 118 & IMD3002_LH_DC == 5540036
replace type_PID = 3 if countryelection_FE == 118 & PID_who == 5540036

replace party_voted = 287 if countryelection_FE == 118 & IMD3002_LH_DC == 5540022 //* Workers' Party
replace party_PID = 287 if countryelection_FE == 118 & PID_who == 5540022
replace type_voted = 6 if countryelection_FE == 118 & IMD3002_LH_DC == 5540022
replace type_PID = 6 if countryelection_FE == 118 & PID_who == 5540022

replace party_voted = 290 if countryelection_FE == 118 & IMD3002_LH_DC == 5540026 //* Kiwi Party
replace party_PID = 290 if countryelection_FE == 118 & PID_who == 5540026
replace type_voted = 7 if countryelection_FE == 118 & IMD3002_LH_DC == 5540026
replace type_PID = 7 if countryelection_FE == 118 & PID_who == 5540026

replace party_voted = 291 if countryelection_FE == 118 & IMD3002_LH_DC == 5540029 //* Family Party
replace party_PID = 291 if countryelection_FE == 118 & PID_who == 5540029
replace type_voted = 3 if countryelection_FE == 118 & IMD3002_LH_DC == 5540029
replace type_PID = 3 if countryelection_FE == 118 & PID_who == 5540029

replace party_voted = 292 if countryelection_FE == 118 & IMD3002_LH_DC == 5540032 //* Residents Action
replace party_PID = 292 if countryelection_FE == 118 & PID_who == 5540032
replace type_voted = 2 if countryelection_FE == 118 & IMD3002_LH_DC == 5540032
replace type_PID = 2 if countryelection_FE == 118 & PID_who == 5540032

replace party_voted = 293 if countryelection_FE == 118 & IMD3002_LH_DC == 5540033 //* Republic of NZ
replace party_PID = 293 if countryelection_FE == 118 & PID_who == 5540033
replace type_voted = 2 if countryelection_FE == 118 & IMD3002_LH_DC == 5540033
replace type_PID = 2 if countryelection_FE == 118 & PID_who == 5540033

replace party_voted = 330 if countryelection_FE == 118 & IMD3002_LH_DC == 5540039 //* Bill and Ben Party
replace party_PID = 330 if countryelection_FE == 118 & PID_who == 5540039
replace type_voted = 2 if countryelection_FE == 118 & IMD3002_LH_DC == 5540039
replace type_PID = 2 if countryelection_FE == 118 & PID_who == 5540039

replace party_voted = 276 if countryelection_FE == 118 & IMD3002_LH_DC == 5540008 //* Maori
replace party_PID = 276 if countryelection_FE == 118 & PID_who == 5540008
replace type_voted = 1 if countryelection_FE == 118 & IMD3002_LH_DC == 5540008
replace type_PID = 1 if countryelection_FE == 118 & PID_who == 5540008

replace party_voted = 282 if countryelection_FE == 118 & IMD3002_LH_DC ==  5540015 //* United NZ
replace party_PID = 282 if countryelection_FE == 118 & PID_who ==  5540015
replace type_voted = 1 if countryelection_FE == 118 & IMD3002_LH_DC ==  5540015
replace type_PID = 1 if countryelection_FE == 118 & PID_who ==  5540015


//* New Zealand 2011

replace incumbent_voted = 1 if countryelection_FE == 119 & IMD3002_LH_DC == 5540001 //* National 
replace incumbent_PID = 1 if countryelection_FE == 119 & PID_who == 5540001

replace party_voted = 269 if countryelection_FE == 119 & IMD3002_LH_DC == 5540001 //* National
replace party_PID = 269 if countryelection_FE == 119 & PID_who == 5540001
replace type_voted = 1 if countryelection_FE == 119 & IMD3002_LH_DC == 5540001
replace type_PID = 1 if countryelection_FE == 119 & PID_who == 5540001

replace party_voted = 270 if countryelection_FE == 119 & IMD3002_LH_DC == 5540002 //* Labour
replace party_PID = 270 if countryelection_FE == 119 & PID_who == 5540002
replace type_voted = 1 if countryelection_FE == 119 & IMD3002_LH_DC == 5540002
replace type_PID = 1 if countryelection_FE == 119 & PID_who == 5540002

replace party_voted = 271 if countryelection_FE == 119 & IMD3002_LH_DC == 5540003 //* NZ First
replace party_PID = 271 if countryelection_FE == 119 & PID_who == 5540003
replace type_voted = 5 if countryelection_FE == 119 & IMD3002_LH_DC == 5540003
replace type_PID = 5 if countryelection_FE == 119 & PID_who == 5540003

replace party_voted = 272 if countryelection_FE == 119 & IMD3002_LH_DC == 5540004 //* ACT
replace party_PID = 272 if countryelection_FE == 119 & PID_who == 5540004
replace type_voted = 7 if countryelection_FE == 119 & IMD3002_LH_DC == 5540004
replace type_PID = 7 if countryelection_FE == 119 & PID_who == 5540004

replace party_voted = 273 if countryelection_FE == 119 & IMD3002_LH_DC == 5540005 //* Greens
replace party_PID = 273 if countryelection_FE == 119 & PID_who == 5540005
replace type_voted = 1 if countryelection_FE == 119 & IMD3002_LH_DC == 5540005
replace type_PID = 1 if countryelection_FE == 119 & PID_who == 5540005

replace party_voted = 274 if countryelection_FE == 119 & IMD3002_LH_DC == 5540006 //* NZ Future
replace party_PID = 274 if countryelection_FE == 119 & PID_who == 5540006
replace type_voted = 1 if countryelection_FE == 119 & IMD3002_LH_DC == 5540006
replace type_PID = 1 if countryelection_FE == 119 & PID_who == 5540006

replace party_voted = 275 if countryelection_FE == 119 & IMD3002_LH_DC == 5540007 //* Conservative Party
replace party_PID = 275 if countryelection_FE == 119 & PID_who == 5540007
replace type_voted = 7 if countryelection_FE == 119 & IMD3002_LH_DC == 5540007
replace type_PID = 7 if countryelection_FE == 119 & PID_who == 5540007

replace party_voted = 277 if countryelection_FE == 119 & IMD3002_LH_DC == 5540009 //* Alliance
replace party_PID = 277 if countryelection_FE == 119 & PID_who == 5540009
replace type_voted = 1 if countryelection_FE == 119 & IMD3002_LH_DC == 5540009
replace type_PID = 1 if countryelection_FE == 119 & PID_who == 5540009

replace party_voted = 279 if countryelection_FE == 119 & IMD3002_LH_DC == 5540011 //* Mana Movement
replace party_PID = 279 if countryelection_FE == 119 & PID_who == 5540011
replace type_voted = 6 if countryelection_FE == 119 & IMD3002_LH_DC == 5540011
replace type_PID = 6 if countryelection_FE == 119 & PID_who == 5540011

replace party_voted = 280 if countryelection_FE == 119 & IMD3002_LH_DC == 5540012 //* Anderton Progressives
replace party_PID = 280 if countryelection_FE == 119 & PID_who == 5540012
replace type_voted = 1 if countryelection_FE == 119 & IMD3002_LH_DC == 5540012
replace type_PID = 1 if countryelection_FE == 119 & PID_who == 5540012

replace party_voted = 328 if countryelection_FE == 119 & IMD3002_LH_DC == 5540013 //* Future NZ
replace party_PID = 328 if countryelection_FE == 119 & PID_who == 5540013
replace type_voted = 1 if countryelection_FE == 119 & IMD3002_LH_DC == 5540013
replace type_PID = 1 if countryelection_FE == 119 & PID_who == 5540013

replace party_voted = 281 if countryelection_FE == 119 & IMD3002_LH_DC == 5540014 //* Christian Heritage
replace party_PID = 281 if countryelection_FE == 119 & PID_who == 5540014
replace type_voted = 3 if countryelection_FE == 119 & IMD3002_LH_DC == 5540014
replace type_PID = 3 if countryelection_FE == 119 & PID_who == 5540014

replace party_voted = 276 if countryelection_FE == 119 & IMD3002_LH_DC == 5540024 | countryelection_FE == 119 & IMD3002_LH_DC == 5540008 //* Mana Motuhake
replace party_PID = 276 if countryelection_FE == 119 & PID_who == 5540024 |  countryelection_FE == 119 & PID_who == 5540008
replace type_voted = 1 if countryelection_FE == 119 & IMD3002_LH_DC == 5540024 |  countryelection_FE == 119 & IMD3002_LH_DC == 5540008
replace type_PID = 1 if countryelection_FE == 119 & PID_who == 5540024 | countryelection_FE == 119 & PID_who == 5540008

replace party_voted = 285 if countryelection_FE == 119 & IMD3002_LH_DC == 5540025 //* Libertarians
replace party_PID = 285 if countryelection_FE == 119 & PID_who == 5540025
replace type_voted = 7 if countryelection_FE == 119 & IMD3002_LH_DC == 5540025
replace type_PID = 7 if countryelection_FE == 119 & PID_who == 5540025

replace party_voted = 286 if countryelection_FE == 119 & IMD3002_LH_DC == 5540021 //* Progressive Greens
replace party_PID = 286 if countryelection_FE == 119 & PID_who == 5540021
replace type_voted = 2 if countryelection_FE == 119 & IMD3002_LH_DC == 5540021
replace type_PID = 2 if countryelection_FE == 119 & PID_who == 5540021

replace party_voted = 288 if countryelection_FE == 119 & IMD3002_LH_DC == 5540023 //* Mana Maori
replace party_PID = 288 if countryelection_FE == 119 & PID_who == 5540023
replace type_voted = 1 if countryelection_FE == 119 & IMD3002_LH_DC == 5540023
replace type_PID = 1 if countryelection_FE == 119 & PID_who == 5540023

replace party_voted = 329 if countryelection_FE == 119 & IMD3002_LH_DC == 5540028 //* NZ Democrats
replace party_PID = 329 if countryelection_FE == 119 & PID_who == 5540028
replace type_voted = 7 if countryelection_FE == 119 & IMD3002_LH_DC == 5540028
replace type_PID = 7 if countryelection_FE == 119 & PID_who == 5540028

replace party_voted = 294 if countryelection_FE == 119 & IMD3002_LH_DC == 5540034 //* McGillicuddy Serious
replace party_PID = 294 if countryelection_FE == 119 & PID_who == 5540034
replace type_voted = 2 if countryelection_FE == 119 & IMD3002_LH_DC == 5540034
replace type_PID = 2 if countryelection_FE == 119 & PID_who == 5540034

replace party_voted = 295 if countryelection_FE == 119 & IMD3002_LH_DC == 5540035 //* Democrats for Social Credit
replace party_PID = 295 if countryelection_FE == 119 & PID_who == 5540035
replace type_voted = 2 if countryelection_FE == 119 & IMD3002_LH_DC == 5540035
replace type_PID = 2 if countryelection_FE == 119 & PID_who == 5540035

replace party_voted = 297 if countryelection_FE == 119 & IMD3002_LH_DC == 5540037 //* Christian Coalition
replace party_PID = 297 if countryelection_FE == 119 & PID_who == 5540037
replace type_voted = 1 if countryelection_FE == 119 & IMD3002_LH_DC == 5540037
replace type_PID = 1 if countryelection_FE == 119 & PID_who == 5540037

replace party_voted = 298 if countryelection_FE == 119 & IMD3002_LH_DC == 5540038 //* Legalise Cannabis
replace party_PID = 298 if countryelection_FE == 119 & PID_who == 5540038
replace type_voted = 2 if countryelection_FE == 119 & IMD3002_LH_DC == 5540038
replace type_PID = 2 if countryelection_FE == 119 & PID_who == 5540038

replace party_voted = 296 if countryelection_FE == 119 & IMD3002_LH_DC == 5540036 //* Outdoor Recreation
replace party_PID = 296 if countryelection_FE == 119 & PID_who == 5540036
replace type_voted = 3 if countryelection_FE == 119 & IMD3002_LH_DC == 5540036
replace type_PID = 3 if countryelection_FE == 119 & PID_who == 5540036

replace party_voted = 287 if countryelection_FE == 119 & IMD3002_LH_DC == 5540022 //* Workers' Party
replace party_PID = 287 if countryelection_FE == 119 & PID_who == 5540022
replace type_voted = 6 if countryelection_FE == 119 & IMD3002_LH_DC == 5540022
replace type_PID = 6 if countryelection_FE == 119 & PID_who == 5540022

replace party_voted = 290 if countryelection_FE == 119 & IMD3002_LH_DC == 5540026 //* Kiwi Party
replace party_PID = 290 if countryelection_FE == 119 & PID_who == 5540026
replace type_voted = 7 if countryelection_FE == 119 & IMD3002_LH_DC == 5540026
replace type_PID = 7 if countryelection_FE == 119 & PID_who == 5540026

replace party_voted = 291 if countryelection_FE == 119 & IMD3002_LH_DC == 5540029 //* Family Party
replace party_PID = 291 if countryelection_FE == 119 & PID_who == 5540029
replace type_voted = 3 if countryelection_FE == 119 & IMD3002_LH_DC == 5540029
replace type_PID = 3 if countryelection_FE == 119 & PID_who == 5540029

replace party_voted = 292 if countryelection_FE == 119 & IMD3002_LH_DC == 5540032 //* Residents Action
replace party_PID = 292 if countryelection_FE == 119 & PID_who == 5540032
replace type_voted = 2 if countryelection_FE == 119 & IMD3002_LH_DC == 5540032
replace type_PID = 2 if countryelection_FE == 119 & PID_who == 5540032

replace party_voted = 293 if countryelection_FE == 119 & IMD3002_LH_DC == 5540033 //* Republic of NZ
replace party_PID = 293 if countryelection_FE == 119 & PID_who == 5540033
replace type_voted = 2 if countryelection_FE == 119 & IMD3002_LH_DC == 5540033
replace type_PID = 2 if countryelection_FE == 119 & PID_who == 5540033

replace party_voted = 330 if countryelection_FE == 119 & IMD3002_LH_DC == 5540039 //* Bill and Ben Party
replace party_PID = 330 if countryelection_FE == 119 & PID_who == 5540039
replace type_voted = 2 if countryelection_FE == 119 & IMD3002_LH_DC == 5540039
replace type_PID = 2 if countryelection_FE == 119 & PID_who == 5540039

replace party_voted = 276 if countryelection_FE == 119 & IMD3002_LH_DC == 5540008 //* Maori
replace party_PID = 276 if countryelection_FE == 119 & PID_who == 5540008
replace type_voted = 1 if countryelection_FE == 119 & IMD3002_LH_DC == 5540008
replace type_PID = 1 if countryelection_FE == 119 & PID_who == 5540008

replace party_voted = 282 if countryelection_FE == 119 & IMD3002_LH_DC ==  5540015 //* United NZ
replace party_PID = 282 if countryelection_FE == 119 & PID_who ==  5540015
replace type_voted = 1 if countryelection_FE == 119 & IMD3002_LH_DC ==  5540015
replace type_PID = 1 if countryelection_FE == 119 & PID_who ==  5540015

//* New Zealand 2014

replace incumbent_voted = 1 if countryelection_FE == 120 & IMD3002_LH_DC == 5540001 //* 	National
replace incumbent_PID = 1 if countryelection_FE == 120 & PID_who == 5540001

replace party_voted = 269 if countryelection_FE == 120 & IMD3002_LH_DC == 5540001 //* National
replace party_PID = 269 if countryelection_FE == 120 & PID_who == 5540001
replace type_voted = 1 if countryelection_FE == 120 & IMD3002_LH_DC == 5540001
replace type_PID = 1 if countryelection_FE == 120 & PID_who == 5540001

replace party_voted = 270 if countryelection_FE == 120 & IMD3002_LH_DC == 5540002 //* Labour
replace party_PID = 270 if countryelection_FE == 120 & PID_who == 5540002
replace type_voted = 1 if countryelection_FE == 120 & IMD3002_LH_DC == 5540002
replace type_PID = 1 if countryelection_FE == 120 & PID_who == 5540002

replace party_voted = 271 if countryelection_FE == 120 & IMD3002_LH_DC == 5540003 //* NZ First
replace party_PID = 271 if countryelection_FE == 120 & PID_who == 5540003
replace type_voted = 5 if countryelection_FE == 120 & IMD3002_LH_DC == 5540003
replace type_PID = 5 if countryelection_FE == 120 & PID_who == 5540003

replace party_voted = 272 if countryelection_FE == 120 & IMD3002_LH_DC == 5540004 //* ACT
replace party_PID = 272 if countryelection_FE == 120 & PID_who == 5540004
replace type_voted = 5 if countryelection_FE == 120 & IMD3002_LH_DC == 5540004
replace type_PID = 5 if countryelection_FE == 120 & PID_who == 5540004

replace party_voted = 273 if countryelection_FE == 120 & IMD3002_LH_DC == 5540005 //* Greens
replace party_PID = 273 if countryelection_FE == 120 & PID_who == 5540005
replace type_voted = 1 if countryelection_FE == 120 & IMD3002_LH_DC == 5540005
replace type_PID = 1 if countryelection_FE == 120 & PID_who == 5540005

replace party_voted = 274 if countryelection_FE == 120 & IMD3002_LH_DC == 5540006 //* NZ Future
replace party_PID = 274 if countryelection_FE == 120 & PID_who == 5540006
replace type_voted = 1 if countryelection_FE == 120 & IMD3002_LH_DC == 5540006
replace type_PID = 1 if countryelection_FE == 120 & PID_who == 5540006

replace party_voted = 275 if countryelection_FE == 120 & IMD3002_LH_DC == 5540007 //* Conservative Party
replace party_PID = 275 if countryelection_FE == 120 & PID_who == 5540007
replace type_voted = 7 if countryelection_FE == 120 & IMD3002_LH_DC == 5540007
replace type_PID = 7 if countryelection_FE == 120 & PID_who == 5540007

replace party_voted = 277 if countryelection_FE == 120 & IMD3002_LH_DC == 5540009 //* Alliance
replace party_PID = 277 if countryelection_FE == 120 & PID_who == 5540009
replace type_voted = 1 if countryelection_FE == 120 & IMD3002_LH_DC == 5540009
replace type_PID = 1 if countryelection_FE == 120 & PID_who == 5540009

replace party_voted = 279 if countryelection_FE == 120 & IMD3002_LH_DC == 5540011 //* Mana Movement
replace party_PID = 279 if countryelection_FE == 120 & PID_who == 5540011
replace type_voted = 6 if countryelection_FE == 120 & IMD3002_LH_DC == 5540011
replace type_PID = 6 if countryelection_FE == 120 & PID_who == 5540011

replace party_voted = 280 if countryelection_FE == 120 & IMD3002_LH_DC == 5540012 //* Anderton Progressives
replace party_PID = 280 if countryelection_FE == 120 & PID_who == 5540012
replace type_voted = 1 if countryelection_FE == 120 & IMD3002_LH_DC == 5540012
replace type_PID = 1 if countryelection_FE == 120 & PID_who == 5540012

replace party_voted = 328 if countryelection_FE == 120 & IMD3002_LH_DC == 5540013 //* Future NZ
replace party_PID = 328 if countryelection_FE == 120 & PID_who == 5540013
replace type_voted = 1 if countryelection_FE == 120 & IMD3002_LH_DC == 5540013
replace type_PID = 1 if countryelection_FE == 120 & PID_who == 5540013

replace party_voted = 281 if countryelection_FE == 120 & IMD3002_LH_DC == 5540014 //* Christian Heritage
replace party_PID = 281 if countryelection_FE == 120 & PID_who == 5540014
replace type_voted = 3 if countryelection_FE == 120 & IMD3002_LH_DC == 5540014
replace type_PID = 3 if countryelection_FE == 120 & PID_who == 5540014

replace party_voted = 276 if countryelection_FE == 120 & IMD3002_LH_DC == 5540024 | countryelection_FE == 120 & IMD3002_LH_DC == 5540008 //* Mana Motuhake
replace party_PID = 276 if countryelection_FE == 120 & PID_who == 5540024 |  countryelection_FE == 120 & PID_who == 5540008
replace type_voted = 1 if countryelection_FE == 120 & IMD3002_LH_DC == 5540024 |  countryelection_FE == 120 & IMD3002_LH_DC == 5540008
replace type_PID = 1 if countryelection_FE == 120 & PID_who == 5540024 | countryelection_FE == 120 & PID_who == 5540008

replace party_voted = 285 if countryelection_FE == 120 & IMD3002_LH_DC == 5540025 //* Libertarians
replace party_PID = 285 if countryelection_FE == 120 & PID_who == 5540025
replace type_voted = 7 if countryelection_FE == 120 & IMD3002_LH_DC == 5540025
replace type_PID = 7 if countryelection_FE == 120 & PID_who == 5540025

replace party_voted = 286 if countryelection_FE == 120 & IMD3002_LH_DC == 5540021 //* Progressive Greens
replace party_PID = 286 if countryelection_FE == 120 & PID_who == 5540021
replace type_voted = 2 if countryelection_FE == 120 & IMD3002_LH_DC == 5540021
replace type_PID = 2 if countryelection_FE == 120 & PID_who == 5540021

replace party_voted = 288 if countryelection_FE == 120 & IMD3002_LH_DC == 5540023 //* Mana Maori
replace party_PID = 288 if countryelection_FE == 120 & PID_who == 5540023
replace type_voted = 1 if countryelection_FE == 120 & IMD3002_LH_DC == 5540023
replace type_PID = 1 if countryelection_FE == 120 & PID_who == 5540023

replace party_voted = 329 if countryelection_FE == 120 & IMD3002_LH_DC == 5540028 //* NZ Democrats
replace party_PID = 329 if countryelection_FE == 120 & PID_who == 5540028
replace type_voted = 7 if countryelection_FE == 120 & IMD3002_LH_DC == 5540028
replace type_PID = 7 if countryelection_FE == 120 & PID_who == 5540028

replace party_voted = 294 if countryelection_FE == 120 & IMD3002_LH_DC == 5540034 //* McGillicuddy Serious
replace party_PID = 294 if countryelection_FE == 120 & PID_who == 5540034
replace type_voted = 2 if countryelection_FE == 120 & IMD3002_LH_DC == 5540034
replace type_PID = 2 if countryelection_FE == 120 & PID_who == 5540034

replace party_voted = 295 if countryelection_FE == 120 & IMD3002_LH_DC == 5540035 //* Democrats for Social Credit
replace party_PID = 295 if countryelection_FE == 120 & PID_who == 5540035
replace type_voted = 2 if countryelection_FE == 120 & IMD3002_LH_DC == 5540035
replace type_PID = 2 if countryelection_FE == 120 & PID_who == 5540035

replace party_voted = 297 if countryelection_FE == 120 & IMD3002_LH_DC == 5540037 //* Christian Coalition
replace party_PID = 297 if countryelection_FE == 120 & PID_who == 5540037
replace type_voted = 1 if countryelection_FE == 120 & IMD3002_LH_DC == 5540037
replace type_PID = 1 if countryelection_FE == 120 & PID_who == 5540037

replace party_voted = 298 if countryelection_FE == 120 & IMD3002_LH_DC == 5540038 //* Legalise Cannabis
replace party_PID = 298 if countryelection_FE == 120 & PID_who == 5540038
replace type_voted = 2 if countryelection_FE == 120 & IMD3002_LH_DC == 5540038
replace type_PID = 2 if countryelection_FE == 120 & PID_who == 5540038

replace party_voted = 296 if countryelection_FE == 120 & IMD3002_LH_DC == 5540036 //* Outdoor Recreation
replace party_PID = 296 if countryelection_FE == 120 & PID_who == 5540036
replace type_voted = 3 if countryelection_FE == 120 & IMD3002_LH_DC == 5540036
replace type_PID = 3 if countryelection_FE == 120 & PID_who == 5540036

replace party_voted = 287 if countryelection_FE == 120 & IMD3002_LH_DC == 5540022 //* Workers' Party
replace party_PID = 287 if countryelection_FE == 120 & PID_who == 5540022
replace type_voted = 6 if countryelection_FE == 120 & IMD3002_LH_DC == 5540022
replace type_PID = 6 if countryelection_FE == 120 & PID_who == 5540022

replace party_voted = 290 if countryelection_FE == 120 & IMD3002_LH_DC == 5540026 //* Kiwi Party
replace party_PID = 290 if countryelection_FE == 120 & PID_who == 5540026
replace type_voted = 7 if countryelection_FE == 120 & IMD3002_LH_DC == 5540026
replace type_PID = 7 if countryelection_FE == 120 & PID_who == 5540026

replace party_voted = 291 if countryelection_FE == 120 & IMD3002_LH_DC == 5540029 //* Family Party
replace party_PID = 291 if countryelection_FE == 120 & PID_who == 5540029
replace type_voted = 3 if countryelection_FE == 120 & IMD3002_LH_DC == 5540029
replace type_PID = 3 if countryelection_FE == 120 & PID_who == 5540029

replace party_voted = 292 if countryelection_FE == 120 & IMD3002_LH_DC == 5540032 //* Residents Action
replace party_PID = 292 if countryelection_FE == 120 & PID_who == 5540032
replace type_voted = 2 if countryelection_FE == 120 & IMD3002_LH_DC == 5540032
replace type_PID = 2 if countryelection_FE == 120 & PID_who == 5540032

replace party_voted = 293 if countryelection_FE == 120 & IMD3002_LH_DC == 5540033 //* Republic of NZ
replace party_PID = 293 if countryelection_FE == 120 & PID_who == 5540033
replace type_voted = 2 if countryelection_FE == 120 & IMD3002_LH_DC == 5540033
replace type_PID = 2 if countryelection_FE == 120 & PID_who == 5540033

replace party_voted = 330 if countryelection_FE == 120 & IMD3002_LH_DC == 5540039 //* Bill and Ben Party
replace party_PID = 330 if countryelection_FE == 120 & PID_who == 5540039
replace type_voted = 2 if countryelection_FE == 120 & IMD3002_LH_DC == 5540039
replace type_PID = 2 if countryelection_FE == 120 & PID_who == 5540039

replace party_voted = 278 if countryelection_FE == 120 & IMD3002_LH_DC == 5540010 //* Internet MANA
replace party_PID = 278 if countryelection_FE == 120 & PID_who == 5540010
replace type_voted = 6 if countryelection_FE == 120 & IMD3002_LH_DC == 5540010
replace type_PID = 6 if countryelection_FE == 120 & PID_who == 5540010

replace party_voted = 284 if countryelection_FE == 120 & IMD3002_LH_DC == 5540018 //* NZ Pacific
replace party_PID = 284 if countryelection_FE == 120 & PID_who == 5540018
replace type_voted = 3 if countryelection_FE == 120 & IMD3002_LH_DC == 5540018
replace type_PID = 3 if countryelection_FE == 120 & PID_who == 5540018

replace party_voted = 276 if countryelection_FE == 120 & IMD3002_LH_DC == 5540008 //* Maori
replace party_PID = 276 if countryelection_FE == 120 & PID_who == 5540008
replace type_voted = 1 if countryelection_FE == 120 & IMD3002_LH_DC == 5540008
replace type_PID = 1 if countryelection_FE == 120 & PID_who == 5540008

replace party_voted = 282 if countryelection_FE == 120 & IMD3002_LH_DC ==  5540015 //* United NZ
replace party_PID = 282 if countryelection_FE == 120 & PID_who ==  5540015
replace type_voted = 1 if countryelection_FE == 120 & IMD3002_LH_DC ==  5540015
replace type_PID = 1 if countryelection_FE == 120 & PID_who ==  5540015



//* Portugal 2002

replace incumbent_voted = 1 if countryelection_FE == 134 & IMD3002_LH_PL == 6200002 //* Socialists
replace incumbent_PID = 1 if countryelection_FE == 134 & PID_who == 6200002

replace party_voted = 165 if countryelection_FE == 134 & IMD3002_LH_PL == 6200001 //* Social Democratic
replace party_PID = 165 if countryelection_FE == 134 & PID_who == 6200001
replace type_voted = 1 if countryelection_FE == 134 & IMD3002_LH_PL == 6200001
replace type_PID = 1 if countryelection_FE == 134 & PID_who == 6200001

replace party_voted = 166 if countryelection_FE == 134 & IMD3002_LH_PL == 6200002 //* Socialists
replace party_PID = 166 if countryelection_FE == 134 & PID_who == 6200002
replace type_voted = 1 if countryelection_FE == 134 & IMD3002_LH_PL == 6200002
replace type_PID = 1 if countryelection_FE == 134 & PID_who == 6200002

replace party_voted = 167 if countryelection_FE == 134 & IMD3002_LH_PL == 6200003 //* CDS - Popular Party
replace party_PID = 167 if countryelection_FE == 134 & PID_who == 6200003
replace type_voted = 1 if countryelection_FE == 134 & IMD3002_LH_PL == 6200003
replace type_PID = 1 if countryelection_FE == 134 & PID_who == 6200003

replace party_voted = 168 if countryelection_FE == 134 & IMD3002_LH_PL == 6200004 | countryelection_FE == 134 & IMD3002_LH_PL == 6200008 //* Unitarian Democratic Coalition (Coms + Greens)
replace party_PID = 168 if countryelection_FE == 134 & PID_who == 6200004 | countryelection_FE == 134 & PID_who == 6200008
replace type_voted = 6 if countryelection_FE == 134 & IMD3002_LH_PL == 6200004 | countryelection_FE == 134 & IMD3002_LH_PL == 6200008
replace type_PID = 6 if countryelection_FE == 134 & PID_who == 6200004 | countryelection_FE == 134 & PID_who == 6200008

replace party_voted = 169 if countryelection_FE == 134 & IMD3002_LH_PL == 6200006 //* Left Bloc
replace party_PID = 169 if countryelection_FE == 134 & PID_who == 6200006
replace type_voted = 6 if countryelection_FE == 134 & IMD3002_LH_PL == 6200006
replace type_PID = 6 if countryelection_FE == 134 & PID_who == 6200006

replace party_voted = 350 if countryelection_FE == 134 & IMD3002_LH_PL == 6200015 //* Monarchists
replace party_PID = 350 if countryelection_FE == 134 & PID_who == 6200015
replace type_voted = 3 if countryelection_FE == 134 & IMD3002_LH_PL == 6200015
replace type_PID = 3 if countryelection_FE == 134 & PID_who == 6200015

replace party_voted = 332 if countryelection_FE == 134 & IMD3002_LH_PL == 6200021 //* Revolutionary Socialists
replace party_PID = 332 if countryelection_FE == 134 & PID_who == 6200021
replace type_voted = 6 if countryelection_FE == 134 & IMD3002_LH_PL == 6200021
replace type_PID = 6 if countryelection_FE == 134 & PID_who == 6200021

replace party_voted = 333 if countryelection_FE == 134 & IMD3002_LH_PL == 6200023 //* Popular Democratic Union
replace party_PID = 333 if countryelection_FE == 134 & PID_who == 6200023
replace type_voted = 6 if countryelection_FE == 134 & IMD3002_LH_PL == 6200023
replace type_PID = 6 if countryelection_FE == 134 & PID_who == 6200023

replace party_voted = 351 if countryelection_FE == 134 & IMD3002_LH_PL == 6200026 //* Humanists
replace party_PID = 351 if countryelection_FE == 134 & PID_who == 6200026
replace type_voted = 2 if countryelection_FE == 134 & IMD3002_LH_PL == 6200026
replace type_PID = 2 if countryelection_FE == 134 & PID_who == 6200026

replace party_voted = 170 if countryelection_FE == 134 & IMD3002_LH_PL == 6200007 //* Workers' Communist
replace party_PID = 170 if countryelection_FE == 134 & PID_who == 6200007
replace type_voted = 6 if countryelection_FE == 134 & IMD3002_LH_PL == 6200007
replace type_PID = 6 if countryelection_FE == 134 & PID_who == 6200007


//* Portugal 2005

replace incumbent_voted = 1 if countryelection_FE == 135 & inlist(IMD3002_LH_PL,6200001,6200003) //* SDP -CDS-PP
replace incumbent_PID = 1 if countryelection_FE == 135 & inlist(PID_who,6200001,6200003) 

replace party_voted = 165 if countryelection_FE == 135 & IMD3002_LH_PL == 6200001 //* Social Democratic
replace party_PID = 165 if countryelection_FE == 135 & PID_who == 6200001
replace type_voted = 1 if countryelection_FE == 135 & IMD3002_LH_PL == 6200001
replace type_PID = 1 if countryelection_FE == 135 & PID_who == 6200001

replace party_voted = 166 if countryelection_FE == 135 & IMD3002_LH_PL == 6200002 //* Socialists
replace party_PID = 166 if countryelection_FE == 135 & PID_who == 6200002
replace type_voted = 1 if countryelection_FE == 135 & IMD3002_LH_PL == 6200002
replace type_PID = 1 if countryelection_FE == 135 & PID_who == 6200002

replace party_voted = 167 if countryelection_FE == 135 & IMD3002_LH_PL == 6200003 //* CDS - Popular Party
replace party_PID = 167 if countryelection_FE == 135 & PID_who == 6200003
replace type_voted = 1 if countryelection_FE == 135 & IMD3002_LH_PL == 6200003
replace type_PID = 1 if countryelection_FE == 135 & PID_who == 6200003

replace party_voted = 168 if countryelection_FE == 135 & IMD3002_LH_PL == 6200004 | countryelection_FE == 135 & IMD3002_LH_PL == 6200008 | countryelection_FE == 135 & IMD3002_LH_PL == 6200005 //* Unitarian Democratic Coalition (Coms + Greens)
replace party_PID = 168 if countryelection_FE == 135 & PID_who == 6200004 | countryelection_FE == 135 & PID_who == 6200008 | countryelection_FE == 135 & PID_who == 6200005
replace type_voted = 6 if countryelection_FE == 135 & IMD3002_LH_PL == 6200004 | countryelection_FE == 135 & IMD3002_LH_PL == 6200008  | countryelection_FE == 135 & IMD3002_LH_PL == 6200005
replace type_PID = 6 if countryelection_FE == 135 & PID_who == 6200004 | countryelection_FE == 135 & PID_who == 6200008 | countryelection_FE == 135 & PID_who == 6200005

replace party_voted = 169 if countryelection_FE == 135 & IMD3002_LH_PL == 6200006 //* Left Bloc
replace party_PID = 169 if countryelection_FE == 135 & PID_who == 6200006
replace type_voted = 6 if countryelection_FE == 135 & IMD3002_LH_PL == 6200006
replace type_PID = 6 if countryelection_FE == 135 & PID_who == 6200006

replace party_voted = 350 if countryelection_FE == 135 & IMD3002_LH_PL == 6200015 //* Monarchists
replace party_PID = 350 if countryelection_FE == 135 & PID_who == 6200015
replace type_voted = 3 if countryelection_FE == 135 & IMD3002_LH_PL == 6200015
replace type_PID = 3 if countryelection_FE == 135 & PID_who == 6200015

replace party_voted = 332 if countryelection_FE == 135 & IMD3002_LH_PL == 6200021 //* Revolutionary Socialists
replace party_PID = 332 if countryelection_FE == 135 & PID_who == 6200021
replace type_voted = 6 if countryelection_FE == 135 & IMD3002_LH_PL == 6200021
replace type_PID = 6 if countryelection_FE == 135 & PID_who == 6200021

replace party_voted = 333 if countryelection_FE == 135 & IMD3002_LH_PL == 6200023 //* Popular Democratic Union
replace party_PID = 333 if countryelection_FE == 135 & PID_who == 6200023
replace type_voted = 6 if countryelection_FE == 135 & IMD3002_LH_PL == 6200023
replace type_PID = 6 if countryelection_FE == 135 & PID_who == 6200023

replace party_voted = 351 if countryelection_FE == 135 & IMD3002_LH_PL == 6200026 //* Humanists
replace party_PID = 351 if countryelection_FE == 135 & PID_who == 6200026
replace type_voted = 2 if countryelection_FE == 135 & IMD3002_LH_PL == 6200026
replace type_PID = 2 if countryelection_FE == 135 & PID_who == 6200026

replace party_voted = 170 if countryelection_FE == 135 & IMD3002_LH_PL == 6200007 //* Workers' Communist
replace party_PID = 170 if countryelection_FE == 135 & PID_who == 6200007
replace type_voted = 6 if countryelection_FE == 135 & IMD3002_LH_PL == 6200007
replace type_PID = 6 if countryelection_FE == 135 & PID_who == 6200007



//* Portugal 2009

replace incumbent_voted = 1 if countryelection_FE == 136 & IMD3002_LH_PL == 6200002 //* Socialists
replace incumbent_PID = 1 if countryelection_FE == 136 & PID_who == 6200002

replace party_voted = 165 if countryelection_FE == 136 & IMD3002_LH_PL == 6200001 //* Social Democratic
replace party_PID = 165 if countryelection_FE == 136 & PID_who == 6200001
replace type_voted = 1 if countryelection_FE == 136 & IMD3002_LH_PL == 6200001
replace type_PID = 1 if countryelection_FE == 136 & PID_who == 6200001

replace party_voted = 166 if countryelection_FE == 136 & IMD3002_LH_PL == 6200002 //* Socialists
replace party_PID = 166 if countryelection_FE == 136 & PID_who == 6200002
replace type_voted = 1 if countryelection_FE == 136 & IMD3002_LH_PL == 6200002
replace type_PID = 1 if countryelection_FE == 136 & PID_who == 6200002

replace party_voted = 167 if countryelection_FE == 136 & IMD3002_LH_PL == 6200003 //* CDS - Popular Party
replace party_PID = 167 if countryelection_FE == 136 & PID_who == 6200003
replace type_voted = 1 if countryelection_FE == 136 & IMD3002_LH_PL == 6200003
replace type_PID = 1 if countryelection_FE == 136 & PID_who == 6200003

replace party_voted = 168 if countryelection_FE == 136 & IMD3002_LH_PL == 6200004 | countryelection_FE == 136 & IMD3002_LH_PL == 6200008 | countryelection_FE == 136 & IMD3002_LH_PL == 6200005 //* Unitarian Democratic Coalition (Coms + Greens)
replace party_PID = 168 if countryelection_FE == 136 & PID_who == 6200004 | countryelection_FE == 136 & PID_who == 6200008 | countryelection_FE == 136 & PID_who == 6200005
replace type_voted = 6 if countryelection_FE == 136 & IMD3002_LH_PL == 6200004 | countryelection_FE == 136 & IMD3002_LH_PL == 6200008  | countryelection_FE == 136 & IMD3002_LH_PL == 6200005
replace type_PID = 6 if countryelection_FE == 136 & PID_who == 6200004 | countryelection_FE == 136 & PID_who == 6200008 | countryelection_FE == 136 & PID_who == 6200005

replace party_voted = 169 if countryelection_FE == 136 & IMD3002_LH_PL == 6200006 //* Left Bloc
replace party_PID = 169 if countryelection_FE == 136 & PID_who == 6200006
replace type_voted = 6 if countryelection_FE == 136 & IMD3002_LH_PL == 6200006
replace type_PID = 6 if countryelection_FE == 136 & PID_who == 6200006

replace party_voted = 350 if countryelection_FE == 136 & IMD3002_LH_PL == 6200015 //* Monarchists
replace party_PID = 350 if countryelection_FE == 136 & PID_who == 6200015
replace type_voted = 3 if countryelection_FE == 136 & IMD3002_LH_PL == 6200015
replace type_PID = 3 if countryelection_FE == 136 & PID_who == 6200015

replace party_voted = 332 if countryelection_FE == 136 & IMD3002_LH_PL == 6200021 //* Revolutionary Socialists
replace party_PID = 332 if countryelection_FE == 136 & PID_who == 6200021
replace type_voted = 6 if countryelection_FE == 136 & IMD3002_LH_PL == 6200021
replace type_PID = 6 if countryelection_FE == 136 & PID_who == 6200021

replace party_voted = 333 if countryelection_FE == 136 & IMD3002_LH_PL == 6200023 //* Popular Democratic Union
replace party_PID = 333 if countryelection_FE == 136 & PID_who == 6200023
replace type_voted = 6 if countryelection_FE == 136 & IMD3002_LH_PL == 6200023
replace type_PID = 6 if countryelection_FE == 136 & PID_who == 6200023

replace party_voted = 351 if countryelection_FE == 136 & IMD3002_LH_PL == 6200026 //* Humanists
replace party_PID = 351 if countryelection_FE == 136 & PID_who == 6200026
replace type_voted = 2 if countryelection_FE == 136 & IMD3002_LH_PL == 6200026
replace type_PID = 2 if countryelection_FE == 136 & PID_who == 6200026

replace party_voted = 171 if countryelection_FE == 136 & IMD3002_LH_PL == 6200009 //* Liberals / Merit and Society
replace party_PID = 171 if countryelection_FE == 136 & PID_who == 6200009
replace type_voted = 3 if countryelection_FE == 136 & IMD3002_LH_PL == 6200009
replace type_PID = 3 if countryelection_FE == 136 & PID_who == 6200009

replace party_voted = 173 if countryelection_FE == 136 & IMD3002_LH_PL == 6200017 //* Earth Party
replace party_PID = 173 if countryelection_FE == 136 & PID_who == 6200017
replace type_voted = 2 if countryelection_FE == 136 & IMD3002_LH_PL == 6200017
replace type_PID = 2 if countryelection_FE == 136 & PID_who == 6200017

replace party_voted = 174 if countryelection_FE == 136 & IMD3002_LH_PL == 6200018 //* Hope for Portugal
replace party_PID = 174 if countryelection_FE == 136 & PID_who == 6200018
replace type_voted = 3 if countryelection_FE == 136 & IMD3002_LH_PL == 6200018
replace type_PID = 3 if countryelection_FE == 136 & PID_who == 6200018

replace party_voted = 170 if countryelection_FE == 136 & IMD3002_LH_PL == 6200007 //* Workers' Communist
replace party_PID = 170 if countryelection_FE == 136 & PID_who == 6200007
replace type_voted = 6 if countryelection_FE == 136 & IMD3002_LH_PL == 6200007
replace type_PID = 6 if countryelection_FE == 136 & PID_who == 6200007


//* Portugal 2015

replace incumbent_voted = 1 if countryelection_FE == 137 & IMD3002_LH_PL == 6200011 //* Portugal Ahead
replace incumbent_PID = 1 if countryelection_FE == 137 & PID_who == 6200011

replace party_voted = 165 if countryelection_FE == 137 & IMD3002_LH_PL == 6200001 //* Social Democratic
replace party_PID = 165 if countryelection_FE == 137 & PID_who == 6200001
replace type_voted = 1 if countryelection_FE == 137 & IMD3002_LH_PL == 6200001
replace type_PID = 1 if countryelection_FE == 137 & PID_who == 6200001

replace party_voted = 166 if countryelection_FE == 137 & IMD3002_LH_PL == 6200002 //* Socialists
replace party_PID = 166 if countryelection_FE == 137 & PID_who == 6200002
replace type_voted = 1 if countryelection_FE == 137 & IMD3002_LH_PL == 6200002
replace type_PID = 1 if countryelection_FE == 137 & PID_who == 6200002

replace party_voted = 167 if countryelection_FE == 137 & IMD3002_LH_PL == 6200003 //* CDS - Popular Party
replace party_PID = 167 if countryelection_FE == 137 & PID_who == 6200003
replace type_voted = 1 if countryelection_FE == 137 & IMD3002_LH_PL == 6200003
replace type_PID = 1 if countryelection_FE == 137 & PID_who == 6200003

replace party_voted = 168 if countryelection_FE == 137 & IMD3002_LH_PL == 6200004 | countryelection_FE == 137 & IMD3002_LH_PL == 6200008 | countryelection_FE == 137 & IMD3002_LH_PL == 6200005 //* Unitarian Democratic Coalition (Coms + Greens)
replace party_PID = 168 if countryelection_FE == 137 & PID_who == 6200004 | countryelection_FE == 137 & PID_who == 6200008 | countryelection_FE == 137 & PID_who == 6200005
replace type_voted = 6 if countryelection_FE == 137 & IMD3002_LH_PL == 6200004 | countryelection_FE == 137 & IMD3002_LH_PL == 6200008  | countryelection_FE == 137 & IMD3002_LH_PL == 6200005
replace type_PID = 6 if countryelection_FE == 137 & PID_who == 6200004 | countryelection_FE == 137 & PID_who == 6200008 | countryelection_FE == 137 & PID_who == 6200005

replace party_voted = 169 if countryelection_FE == 137 & IMD3002_LH_PL == 6200006 //* Left Bloc
replace party_PID = 169 if countryelection_FE == 137 & PID_who == 6200006
replace type_voted = 6 if countryelection_FE == 137 & IMD3002_LH_PL == 6200006
replace type_PID = 6 if countryelection_FE == 137 & PID_who == 6200006

replace party_voted = 350 if countryelection_FE == 137 & IMD3002_LH_PL == 6200015 //* Monarchists
replace party_PID = 350 if countryelection_FE == 137 & PID_who == 6200015
replace type_voted = 3 if countryelection_FE == 137 & IMD3002_LH_PL == 6200015
replace type_PID = 3 if countryelection_FE == 137 & PID_who == 6200015

replace party_voted = 332 if countryelection_FE == 137 & IMD3002_LH_PL == 6200021 //* Revolutionary Socialists
replace party_PID = 332 if countryelection_FE == 137 & PID_who == 6200021
replace type_voted = 6 if countryelection_FE == 137 & IMD3002_LH_PL == 6200021
replace type_PID = 6 if countryelection_FE == 137 & PID_who == 6200021

replace party_voted = 333 if countryelection_FE == 137 & IMD3002_LH_PL == 6200023 //* Popular Democratic Union
replace party_PID = 333 if countryelection_FE == 137 & PID_who == 6200023
replace type_voted = 6 if countryelection_FE == 137 & IMD3002_LH_PL == 6200023
replace type_PID = 6 if countryelection_FE == 137 & PID_who == 6200023

replace party_voted = 351 if countryelection_FE == 137 & IMD3002_LH_PL == 6200026 //* Humanists
replace party_PID = 351 if countryelection_FE == 137 & PID_who == 6200026
replace type_voted = 2 if countryelection_FE == 137 & IMD3002_LH_PL == 6200026
replace type_PID = 2 if countryelection_FE == 137 & PID_who == 6200026

replace party_voted = 171 if countryelection_FE == 137 & IMD3002_LH_PL == 6200009 //* Liberals / Merit and Society
replace party_PID = 171 if countryelection_FE == 137 & PID_who == 6200009
replace type_voted = 3 if countryelection_FE == 137 & IMD3002_LH_PL == 6200009
replace type_PID = 3 if countryelection_FE == 137 & PID_who == 6200009

replace party_voted = 173 if countryelection_FE == 137 & IMD3002_LH_PL == 6200017 //* Earth Party
replace party_PID = 173 if countryelection_FE == 137 & PID_who == 6200017
replace type_voted = 2 if countryelection_FE == 137 & IMD3002_LH_PL == 6200017
replace type_PID = 2 if countryelection_FE == 137 & PID_who == 6200017

replace party_voted = 174 if countryelection_FE == 137 & IMD3002_LH_PL == 6200018 //* Hope for Portugal
replace party_PID = 174 if countryelection_FE == 137 & PID_who == 6200018
replace type_voted = 3 if countryelection_FE == 137 & IMD3002_LH_PL == 6200018
replace type_PID = 3 if countryelection_FE == 137 & PID_who == 6200018

replace party_voted = 172 if countryelection_FE == 137 & IMD3002_LH_PL == 6200011 //* Portugal Ahead
replace party_PID = 172 if countryelection_FE == 137 & PID_who == 6200011
replace type_voted = 1 if countryelection_FE == 137 & IMD3002_LH_PL == 6200011
replace type_PID = 1 if countryelection_FE == 137 & PID_who == 6200011

replace party_voted = 170 if countryelection_FE == 137 & IMD3002_LH_PL == 6200007 //* Workers' Communist
replace party_PID = 170 if countryelection_FE == 137 & PID_who == 6200007
replace type_voted = 6 if countryelection_FE == 137 & IMD3002_LH_PL == 6200007
replace type_PID = 6 if countryelection_FE == 137 & PID_who == 6200007


//* Sweden 1998

replace incumbent_voted = 1 if countryelection_FE == 153 & IMD3002_LH_PL == 7520001 //*Social Democratic
replace incumbent_PID = 1 if countryelection_FE == 153 & PID_who == 7520001

replace party_voted = 193 if countryelection_FE == 153 & IMD3002_LH_PL == 7520001 //* Social Democratic
replace party_PID = 193 if countryelection_FE == 153 & PID_who == 7520001
replace type_voted = 1 if countryelection_FE == 153 & IMD3002_LH_PL == 7520001
replace type_PID = 1 if countryelection_FE == 153 & PID_who == 7520001

replace party_voted = 194 if countryelection_FE == 153 & IMD3002_LH_PL == 7520002 //* Moderate Party
replace party_PID = 194 if countryelection_FE == 153 & PID_who == 7520002
replace type_voted = 1 if countryelection_FE == 153 & IMD3002_LH_PL == 7520002
replace type_PID = 1 if countryelection_FE == 153 & PID_who == 7520002

replace party_voted = 195 if countryelection_FE == 153 & IMD3002_LH_PL == 7520003 //* Liberal People's Party
replace party_PID = 195 if countryelection_FE == 153 & PID_who == 7520003
replace type_voted = 1 if countryelection_FE == 153 & IMD3002_LH_PL == 7520003
replace type_PID = 1 if countryelection_FE == 153 & PID_who == 7520003

replace party_voted = 196 if countryelection_FE == 153 & IMD3002_LH_PL == 7520004 //* Christian Democrats
replace party_PID = 196 if countryelection_FE == 153 & PID_who == 7520004
replace type_voted = 1 if countryelection_FE == 153 & IMD3002_LH_PL == 7520004
replace type_PID = 1 if countryelection_FE == 153 & PID_who == 7520004

replace party_voted = 197 if countryelection_FE == 153 & IMD3002_LH_PL == 7520005 //* Greens
replace party_PID = 197 if countryelection_FE == 153 & PID_who == 7520005
replace type_voted = 6 if countryelection_FE == 153 & IMD3002_LH_PL == 7520005
replace type_PID = 6 if countryelection_FE == 153 & PID_who == 7520005

replace party_voted = 198 if countryelection_FE == 153 & IMD3002_LH_PL == 7520006 //* Centre Party
replace party_PID = 198 if countryelection_FE == 153 & PID_who == 7520006
replace type_voted = 1 if countryelection_FE == 153 & IMD3002_LH_PL == 7520006
replace type_PID = 1 if countryelection_FE == 153 & PID_who == 7520006

replace party_voted = 199 if countryelection_FE == 153 & IMD3002_LH_PL == 7520007 //* Left Party
replace party_PID = 199 if countryelection_FE == 153 & PID_who == 7520007
replace type_voted = 6 if countryelection_FE == 153 & IMD3002_LH_PL == 7520007
replace type_PID = 6 if countryelection_FE == 153 & PID_who == 7520007




//* Sweden 2002

replace incumbent_voted = 1 if countryelection_FE == 154 & IMD3002_LH_PL == 7520001 //*Social Democratic
replace incumbent_PID = 1 if countryelection_FE == 154 & PID_who == 7520001

replace party_voted = 193 if countryelection_FE == 154 & IMD3002_LH_PL == 7520001 //* Social Democratic
replace party_PID = 193 if countryelection_FE == 154 & PID_who == 7520001
replace type_voted = 1 if countryelection_FE == 154 & IMD3002_LH_PL == 7520001
replace type_PID = 1 if countryelection_FE == 154 & PID_who == 7520001

replace party_voted = 194 if countryelection_FE == 154 & IMD3002_LH_PL == 7520002 //* Moderate Party
replace party_PID = 194 if countryelection_FE == 154 & PID_who == 7520002
replace type_voted = 1 if countryelection_FE == 154 & IMD3002_LH_PL == 7520002
replace type_PID = 1 if countryelection_FE == 154 & PID_who == 7520002

replace party_voted = 195 if countryelection_FE == 154 & IMD3002_LH_PL == 7520003 //* Liberal People's Party
replace party_PID = 195 if countryelection_FE == 154 & PID_who == 7520003
replace type_voted = 1 if countryelection_FE == 154 & IMD3002_LH_PL == 7520003
replace type_PID = 1 if countryelection_FE == 154 & PID_who == 7520003

replace party_voted = 196 if countryelection_FE == 154 & IMD3002_LH_PL == 7520004 //* Christian Democrats
replace party_PID = 196 if countryelection_FE == 154 & PID_who == 7520004
replace type_voted = 1 if countryelection_FE == 154 & IMD3002_LH_PL == 7520004
replace type_PID = 1 if countryelection_FE == 154 & PID_who == 7520004

replace party_voted = 197 if countryelection_FE == 154 & IMD3002_LH_PL == 7520005 //* Greens
replace party_PID = 197 if countryelection_FE == 154 & PID_who == 7520005
replace type_voted = 6 if countryelection_FE == 154 & IMD3002_LH_PL == 7520005
replace type_PID = 6 if countryelection_FE == 154 & PID_who == 7520005

replace party_voted = 198 if countryelection_FE == 154 & IMD3002_LH_PL == 7520006 //* Centre Party
replace party_PID = 198 if countryelection_FE == 154 & PID_who == 7520006
replace type_voted = 1 if countryelection_FE == 154 & IMD3002_LH_PL == 7520006
replace type_PID = 1 if countryelection_FE == 154 & PID_who == 7520006

replace party_voted = 199 if countryelection_FE == 154 & IMD3002_LH_PL == 7520007 //* Left Party
replace party_PID = 199 if countryelection_FE == 154 & PID_who == 7520007
replace type_voted = 6 if countryelection_FE == 154 & IMD3002_LH_PL == 7520007
replace type_PID = 6 if countryelection_FE == 154 & PID_who == 7520007

replace party_voted = 200 if countryelection_FE == 154 & IMD3002_LH_PL == 7520008 //* Sweden Democrats
replace party_PID = 200 if countryelection_FE == 154 & PID_who == 7520008
replace type_voted = 7 if countryelection_FE == 154 & IMD3002_LH_PL == 7520008
replace type_PID = 7 if countryelection_FE == 154 & PID_who == 7520008

replace party_voted = 201 if countryelection_FE == 154 & IMD3002_LH_PL == 7520009 //* Feminist Initaitve
replace party_PID = 201 if countryelection_FE == 154 & PID_who == 7520009
replace type_voted = 6 if countryelection_FE == 154 & IMD3002_LH_PL == 7520009
replace type_PID = 6 if countryelection_FE == 154 & PID_who == 7520009

//* Sweden 2006

replace incumbent_voted = 1 if countryelection_FE == 155 & IMD3002_LH_PL == 7520001 //*Social Democratic
replace incumbent_PID = 1 if countryelection_FE == 155 & PID_who == 7520001

replace party_voted = 193 if countryelection_FE == 155 & IMD3002_LH_PL == 7520001 //* Social Democratic
replace party_PID = 193 if countryelection_FE == 155 & PID_who == 7520001
replace type_voted = 1 if countryelection_FE == 155 & IMD3002_LH_PL == 7520001
replace type_PID = 1 if countryelection_FE == 155 & PID_who == 7520001

replace party_voted = 194 if countryelection_FE == 155 & IMD3002_LH_PL == 7520002 //* Moderate Party
replace party_PID = 194 if countryelection_FE == 155 & PID_who == 7520002
replace type_voted = 1 if countryelection_FE == 155 & IMD3002_LH_PL == 7520002
replace type_PID = 1 if countryelection_FE == 155 & PID_who == 7520002

replace party_voted = 195 if countryelection_FE == 155 & IMD3002_LH_PL == 7520003 //* Liberal People's Party
replace party_PID = 195 if countryelection_FE == 155 & PID_who == 7520003
replace type_voted = 1 if countryelection_FE == 155 & IMD3002_LH_PL == 7520003
replace type_PID = 1 if countryelection_FE == 155 & PID_who == 7520003

replace party_voted = 196 if countryelection_FE == 155 & IMD3002_LH_PL == 7520004 //* Christian Democrats
replace party_PID = 196 if countryelection_FE == 155 & PID_who == 7520004
replace type_voted = 1 if countryelection_FE == 155 & IMD3002_LH_PL == 7520004
replace type_PID = 1 if countryelection_FE == 155 & PID_who == 7520004

replace party_voted = 197 if countryelection_FE == 155 & IMD3002_LH_PL == 7520005 //* Greens
replace party_PID = 197 if countryelection_FE == 155 & PID_who == 7520005
replace type_voted = 4 if countryelection_FE == 155 & IMD3002_LH_PL == 7520005
replace type_PID = 4 if countryelection_FE == 155 & PID_who == 7520005

replace party_voted = 198 if countryelection_FE == 155 & IMD3002_LH_PL == 7520006 //* Centre Party
replace party_PID = 198 if countryelection_FE == 155 & PID_who == 7520006
replace type_voted = 1 if countryelection_FE == 155 & IMD3002_LH_PL == 7520006
replace type_PID = 1 if countryelection_FE == 155 & PID_who == 7520006

replace party_voted = 199 if countryelection_FE == 155 & IMD3002_LH_PL == 7520007 //* Left Party
replace party_PID = 199 if countryelection_FE == 155 & PID_who == 7520007
replace type_voted = 4 if countryelection_FE == 155 & IMD3002_LH_PL == 7520007
replace type_PID = 4 if countryelection_FE == 155 & PID_who == 7520007

replace party_voted = 200 if countryelection_FE == 155 & IMD3002_LH_PL == 7520008 //* Sweden Democrats
replace party_PID = 200 if countryelection_FE == 155 & PID_who == 7520008
replace type_voted = 7 if countryelection_FE == 155 & IMD3002_LH_PL == 7520008
replace type_PID = 7 if countryelection_FE == 155 & PID_who == 7520008

replace party_voted = 201 if countryelection_FE == 155 & IMD3002_LH_PL == 7520009 //* Feminist Initaitve
replace party_PID = 201 if countryelection_FE == 155 & PID_who == 7520009
replace type_voted = 6 if countryelection_FE == 155 & IMD3002_LH_PL == 7520009
replace type_PID = 6 if countryelection_FE == 155 & PID_who == 7520009

//* Sweden 2014

replace incumbent_voted = 1 if countryelection_FE == 156 & inlist(IMD3002_LH_PL,7520002,7520003,7520006,7520004) //* Mod, Lib, Centre, Christ Dem
replace incumbent_PID = 1 if countryelection_FE == 156 & inlist(PID_who,7520002,7520003,7520006,7520004)

replace party_voted = 193 if countryelection_FE == 156 & IMD3002_LH_PL == 7520001 //* Social Democratic
replace party_PID = 193 if countryelection_FE == 156 & PID_who == 7520001
replace type_voted = 1 if countryelection_FE == 156 & IMD3002_LH_PL == 7520001
replace type_PID = 1 if countryelection_FE == 156 & PID_who == 7520001

replace party_voted = 194 if countryelection_FE == 156 & IMD3002_LH_PL == 7520002 //* Moderate Party
replace party_PID = 194 if countryelection_FE == 156 & PID_who == 7520002
replace type_voted = 1 if countryelection_FE == 156 & IMD3002_LH_PL == 7520002
replace type_PID = 1 if countryelection_FE == 156 & PID_who == 7520002

replace party_voted = 195 if countryelection_FE == 156 & IMD3002_LH_PL == 7520003 //* Liberal People's Party
replace party_PID = 195 if countryelection_FE == 156 & PID_who == 7520003
replace type_voted = 1 if countryelection_FE == 156 & IMD3002_LH_PL == 7520003
replace type_PID = 1 if countryelection_FE == 156 & PID_who == 7520003

replace party_voted = 196 if countryelection_FE == 156 & IMD3002_LH_PL == 7520004 //* Christian Democrats
replace party_PID = 196 if countryelection_FE == 156 & PID_who == 7520004
replace type_voted = 1 if countryelection_FE == 156 & IMD3002_LH_PL == 7520004
replace type_PID = 1 if countryelection_FE == 156 & PID_who == 7520004

replace party_voted = 197 if countryelection_FE == 156 & IMD3002_LH_PL == 7520005 //* Greens
replace party_PID = 197 if countryelection_FE == 156 & PID_who == 7520005
replace type_voted = 1 if countryelection_FE == 156 & IMD3002_LH_PL == 7520005
replace type_PID = 1 if countryelection_FE == 156 & PID_who == 7520005

replace party_voted = 198 if countryelection_FE == 156 & IMD3002_LH_PL == 7520006 //* Centre Party
replace party_PID = 198 if countryelection_FE == 156 & PID_who == 7520006
replace type_voted = 1 if countryelection_FE == 156 & IMD3002_LH_PL == 7520006
replace type_PID = 1 if countryelection_FE == 156 & PID_who == 7520006

replace party_voted = 199 if countryelection_FE == 156 & IMD3002_LH_PL == 7520007 //* Left Party
replace party_PID = 199 if countryelection_FE == 156 & PID_who == 7520007
replace type_voted = 4 if countryelection_FE == 156 & IMD3002_LH_PL == 7520007
replace type_PID = 4 if countryelection_FE == 156 & PID_who == 7520007

replace party_voted = 200 if countryelection_FE == 156 & IMD3002_LH_PL == 7520008 //* Sweden Democrats
replace party_PID = 200 if countryelection_FE == 156 & PID_who == 7520008
replace type_voted = 7 if countryelection_FE == 156 & IMD3002_LH_PL == 7520008
replace type_PID = 7 if countryelection_FE == 156 & PID_who == 7520008

replace party_voted = 201 if countryelection_FE == 156 & IMD3002_LH_PL == 7520009 //* Feminist Initaitve
replace party_PID = 201 if countryelection_FE == 156 & PID_who == 7520009
replace type_voted = 6 if countryelection_FE == 156 & IMD3002_LH_PL == 7520009
replace type_PID = 6 if countryelection_FE == 156 & PID_who == 7520009

replace incumbent_voted = 0 if incumbent_voted != 1 & IMD3002_LH_PL != 9999997 & IMD3002_LH_DC != 9999997 //* Exclude those who refused to give vote choice as may have voted inc. 

gen mainstream_PID = 1 if PID_dummy == 1 & type_PID == 1
replace mainstream_PID = 0 if mainstream_PID != 1

gen incummainstream_PID = 1 if PID_dummy == 1 & type_PID == 1 & incumbent_PID == 1
replace incummainstream_PID = 0 if incummainstream_PID != 1

label variable mainstream_PID "Respondent has PID (at least 'somewhat close') with Mainstream Party"
label variable incummainstream_PID "Respondent has PID (at least 'somewhat close') with Incumbent Mainstream Party"

*********************************************************************************************************************************************************************************************************

**** Dependent Variables ***

gen votechoice =.
label variable votechoice "Vote Choice: Incum MS, Opposition MS, CP, HWH, ASP, Abstain"
replace votechoice = 1 if type_voted == 1 & incumbent_voted == 1
replace votechoice = 2 if type_voted == 1 & incumbent_voted == 0
replace votechoice = 3 if type_voted == 2 | type_voted == 3
replace votechoice = 4 if type_voted == 4 | type_voted == 5
replace votechoice = 5 if type_voted == 6 | type_voted == 7
replace votechoice = 6 if turnout == 0
label define votechoice 1 "Mainstream Party Incumbent" 2 "Mainstream Opposition" 3 "Complementary Party" 4 "Halfway-House Party" 5 "Anti-System Party" 6 "Abstain"
label values votechoice votechoice

gen reduced_votechoice1 =.
label variable reduced_votechoice1 "Vote Choice: MS, CP, HWH, ASP, Abstain"
replace reduced_votechoice1 = 1 if type_voted == 1 
replace reduced_votechoice1 = 2 if type_voted == 2 | type_voted == 3
replace reduced_votechoice1 = 3 if type_voted == 4 | type_voted == 5
replace reduced_votechoice1 = 4 if type_voted == 6 | type_voted == 7
replace reduced_votechoice1 = 5 if turnout == 0
label define reduced_votechoice1 1 "Mainstream Party " 2 "Complementary Party" 3 "Halfway-House Party" 4 "Anti-System Party" 5 "Abstain"
label values reduced_votechoice1 reduced_votechoice1

gen extended_votechoice =.
label variable extended_votechoice "Vote Choice: Incum MS, Opposition MS, LWCP, RWCP, LWHWH, RWHWH, LWASP, RWASP, Abstain"
replace extended_votechoice = 1 if type_voted == 1 & incumbent_voted == 1
replace extended_votechoice = 2 if type_voted == 1 & incumbent_voted == 0
replace extended_votechoice = 3 if type_voted == 2 
replace extended_votechoice = 4 if type_voted == 3
replace extended_votechoice = 5 if type_voted == 4
replace extended_votechoice = 6 if type_voted == 5
replace extended_votechoice = 7 if type_voted == 6 
replace extended_votechoice = 8 if type_voted == 7
replace extended_votechoice = 9 if turnout == 0
label define extended_votechoice 1 "Mainstream Party Incumbent" 2 "Mainstream Opposition" 3 "LW Complementary Party" 4 "RW Complementary Party" 5 "LW Halfway-House Party" 6 "RW Halfway-House Party" 7 "LW Anti-System Party" 8 "RW Anti-System Party" 9 "Abstain"
label values extended_votechoice extended_votechoice

gen reduced_votechoice2 =.
label variable reduced_votechoice2 "Vote Choice: MS Party, LWCP, RWCP, LWHWH, RWHWH, LWASP, RWASP, Abstain"
replace reduced_votechoice2 = 1 if type_voted == 1
replace reduced_votechoice2 = 2 if type_voted == 2 
replace reduced_votechoice2 = 3 if type_voted == 3
replace reduced_votechoice2 = 4 if type_voted == 4
replace reduced_votechoice2 = 5 if type_voted == 5
replace reduced_votechoice2 = 6 if type_voted == 6 
replace reduced_votechoice2 = 7 if type_voted == 7
replace reduced_votechoice2 = 8 if turnout == 0
label define reduced_votechoice2 1 "Mainstream Party" 2 "LW Complementary Party" 3 "RW Complementary Party" 4 "LW Halfway-House Party" 5 "RW Halfway-House Party" 6 "LW Anti-System Party" 7 "RW Anti-System Party" 8 "Abstain"
label values reduced_votechoice2 reduced_votechoice2

gen PID_votechoice =.
label variable PID_votechoice "Respondent Partisanship (Vote Choice Variable)"
label define PID_votechoice 1 "Mainstream Party Incumbent" 2 "Mainstream Opposition" 3 "Complementary Party" 4 "Halfway-House Party" 5 "Anti-System Party" 6 "No PID"
label values PID_votechoice PID_votechoice
replace PID_votechoice = 1 if type_PID == 1 & PID_dummy == 1 & incumbent_PID == 1
replace PID_votechoice = 2 if type_PID == 1 & PID_dummy == 1 & incumbent_PID != 1
replace PID_votechoice = 3 if type_PID == 2 & PID_dummy == 1 | type_PID == 3 & PID_dummy == 1 
replace PID_votechoice = 4 if type_PID == 4 & PID_dummy == 1 | type_PID == 5 & PID_dummy == 1 
replace PID_votechoice = 5 if type_PID == 6 & PID_dummy == 1 | type_PID == 7 & PID_dummy == 1 
replace PID_votechoice = 6 if PID_dummy != 1

gen PID_reducedvotechoice =.
label variable PID_reducedvotechoice "Respondent Partisanship (Reduced Vote Choice Variable)"
label define PID_reducedvotechoice 1 "Mainstream Party " 2 "Complementary Party" 3 "Halfway-House Party" 4 "Anti-System Party" 5 "No PID"
label values PID_reducedvotechoice PID_reducedvotechoice
replace PID_reducedvotechoice = 1 if type_PID == 1 & PID_dummy == 1 
replace PID_reducedvotechoice = 2 if type_PID == 2 & PID_dummy == 1 | type_PID == 3 & PID_dummy == 1 
replace PID_reducedvotechoice = 3 if type_PID == 4 & PID_dummy == 1 | type_PID == 5 & PID_dummy == 1 
replace PID_reducedvotechoice = 4 if type_PID == 6 & PID_dummy == 1 | type_PID == 7 & PID_dummy == 1 
replace PID_reducedvotechoice = 5 if PID_dummy != 1

gen PID_extendedvotechoice =.
label variable PID_extendedvotechoice "Respondent Partisanship (Extended Vote Choice Variable)"
label define PID_extendedvotechoice  1 "Mainstream Party Incumbent" 2 "Mainstream Opposition" 3 "LW Complementary Party" 4 "RW Complementary Party" 5 "LW Halfway-House Party" 6 "RW Halfway-House Party" 7 "LW Anti-System Party" 8 "RW Anti-System Party" 9 "No PID"
label values PID_extendedvotechoice PID_extendedvotechoice
replace PID_extendedvotechoice = 1 if type_PID == 1 & PID_dummy == 1 & incumbent_PID == 1
replace PID_extendedvotechoice = 2 if type_PID == 1 & PID_dummy == 1 & incumbent_PID != 1
replace PID_extendedvotechoice = 3 if type_PID == 2 & PID_dummy == 1 
replace PID_extendedvotechoice = 4 if type_PID == 3 & PID_dummy == 1 
replace PID_extendedvotechoice = 5 if type_PID == 4 & PID_dummy == 1 
replace PID_extendedvotechoice = 6 if type_PID == 5 & PID_dummy == 1 
replace PID_extendedvotechoice = 7 if type_PID == 6 & PID_dummy == 1 
replace PID_extendedvotechoice = 8 if type_PID == 7 & PID_dummy == 1
replace PID_extendedvotechoice = 9 if PID_dummy != 1

gen PID_reducedvotechoice2 =.
label variable PID_reducedvotechoice2 "Respondent Partisanship (Reduced Vote Choice 2 Variable)"
label define PID_reducedvotechoice2  1 "Mainstream Party" 2 "LW Complementary Party" 3 "RW Complementary Party" 4 "LW Halfway-House Party" 5 "RW Halfway-House Party" 6 "LW Anti-System Party" 7 "RW Anti-System Party" 8 "No PID"
label values PID_reducedvotechoice2 PID_reducedvotechoice2
replace PID_reducedvotechoice2 = 1 if type_PID == 1 & PID_dummy == 1
replace PID_reducedvotechoice2 = 2 if type_PID == 2 & PID_dummy == 1 
replace PID_reducedvotechoice2 = 3 if type_PID == 3 & PID_dummy == 1 
replace PID_reducedvotechoice2 = 4 if type_PID == 4 & PID_dummy == 1 
replace PID_reducedvotechoice2 = 5 if type_PID == 5 & PID_dummy == 1 
replace PID_reducedvotechoice2 = 6 if type_PID == 6 & PID_dummy == 1 
replace PID_reducedvotechoice2 = 7 if type_PID == 7 & PID_dummy == 1
replace PID_reducedvotechoice2 = 8 if PID_dummy != 1

order incumbent_PID party_PID type_PID mainstream_PID incummainstream_PID ///
PID_votechoice PID_reducedvotechoice PID_extendedvotechoice PID_reducedvotechoice2 party_voted ///
type_voted incumbent_voted votechoice reduced_votechoice1 extended_votechoice reduced_votechoice2, after(PID_who)
drop list_dom turnout_1 type_votedSHORT type_votedLONG
drop votesA - MSRANKER
set matsize 800

save "$data2\CSESedit.dta", replace

gen master_id = (_n + 16363)

foreach var of varlist country_FE - vote_partyI {
        rename `var' cses_`var'
}

drop cses_respondent_ID 

///* Generate Unified Variables


gen unified_respondentID = master_id
label variable unified_respondentID "Unique Respondent ID Number"

gen unified_surveywave =.
replace unified_surveywave = 1 if cses_wave == 1
replace unified_surveywave = 2 if cses_wave == 2
replace unified_surveywave = 3 if cses_wave == 3
replace unified_surveywave = 4 if cses_wave == 4
label variable unified_surveywave "Fixed-Effect for Survey Wave"
label define unified_surveywave 1 "CSES Wave 1 (1996-01)" 2 "CSES Wave 2 (2001-06)" 3 "CSES Wave 3 (2006-11)" 4 "CSES Wave 4 (2011-16)" 
label values unified_surveywave unified_surveywave

gen unified_countryFE =.
label variable unified_countryFE "Fixed-Effect for Country"
label define unified_countryFE 1 "Australia" 2 "Austria" 3 "Belgium" 4 "Canada" 5 "Denmark" 6 "Finland" 7 "France" 8 "Germany" 9 "Great Britain" 10 "Greece" ///
                              11 "Iceland" 12 "Ireland" 13 "Italy" 14 "Netherlands" 15 "New Zealand" 16 "Norway" 17 "Portugal" 18 "Spain" 19 "Sweden" /// 
                              20 "Switzerland" 
label values unified_countryFE unified_countryFE	
	
replace unified_countryFE = 1 if cses_country_FE == 3 //* Australia
replace unified_countryFE = 2 if cses_country_FE == 4  //* Austria
replace unified_countryFE = 3 if cses_country_FE == 6 //* Belgium
replace unified_countryFE = 4 if cses_country_FE == 9 //* Canada
replace unified_countryFE = 5 if cses_country_FE == 13 //* Denmark
replace unified_countryFE = 6 if cses_country_FE == 15  //* Finland
replace unified_countryFE = 7 if cses_country_FE == 16  //* France
replace unified_countryFE = 8 if cses_country_FE == 17  //* Germany
replace unified_countryFE = 9 if cses_country_FE == 18 //* Great Britain
replace unified_countryFE = 10 if cses_country_FE == 19   //* Greece
replace unified_countryFE = 11 if cses_country_FE == 22 //* Iceland
replace unified_countryFE = 12 if cses_country_FE == 23  //* Ireland 
replace unified_countryFE = 13 if cses_country_FE == 25  //* Italy 
replace unified_countryFE = 14 if cses_country_FE == 33  //* Netherlands
replace unified_countryFE = 15 if cses_country_FE == 34 //* New Zealand
replace unified_countryFE = 16 if cses_country_FE == 35 // * Norway
replace unified_countryFE = 17 if cses_country_FE == 39  //* Portugal
replace unified_countryFE = 18 if cses_country_FE == 47 //* Spain
replace unified_countryFE = 19 if cses_country_FE == 48  //* Sweden
replace unified_countryFE = 20 if cses_country_FE == 49 //* Switzerland

				  						 
gen unified_countrysurveyFE =.
label variable unified_countrysurveyFE "Fixed-Effect for Country-Survey Year"
label define unified_countrysurveyFE 1 "Australia_1996" 2 "Australia_2004" 3 "Australia_2007" 4 "Australia_2013" ///
                                     5 "Austria_2008"   6 "Austria_2013" ///
									 7 "Bel_Flanders_1999"  8 "Bel_Wallonia_1999" 9 "Belgium_2003" ///
									 10 "Canada_1997" 11 "Canada_2004" 12 "Canada_2008" 13 "Canada_2011" 14 "Canada_2015" ///
									 15 "Switzerland_1999" 16 "Switzerland_2003" 17 "Switzerland_2007" 18 "Switzerland_2011" ///
									 19 "Germany_2002a" 20 "Germany_20002b" 21 "Germany_2005" 22 "Germany_2009" 23 "Germany_2013" ///
									 24 "Denmark_1998" 25 "Denmark_2001" 26 "Denmark_2007" ///
									 27 "Spain_1996" 28 "Spain_2000" 29 "Spain_2004" 30 "Spain_2008" ///
									 31 "Finland_2003" 32 "Finland_2007" 33 "Finland_2011" 34 "Finland_2015" ///
									 35 "France_2007" ///
									 36 "Britain_1997" 37 "Britain_2005" 38 "Britain_2015" ///
									 39 "Greece_2009" 40 "Greece_2012" 41 "Greece_2015" ///
									 42 "Ireland_2002" 43 "Ireland_2007" 44 "Ireland_2011" ///
									 45 "Iceland_1999" 46 "Iceland_2003" 47 "Iceland_2007" 48 "Iceland_2009" 49 "Iceland_2013" ///
									 50 "Italy_2006" ///
									 51 "Netherlands_1998" 52 "Netherlands_2002" 53 "Netherlands_2006" 54 "Netherlands_2010" ///
									 55 "Norway_1997" 56 "Norway_2001" 57 "Norway_2005" 58 "Norway_2009" 59 "Norway_2013" ///
									 60 "NewZealand_1996" 61 "NewZealand_2002" 62 "NewZealand_2008" 63 "NewZealand_2011" 64 "NewZealand_2014" ///
									 65 "Portugal_2002" 66 "Portugal_2005" 67 "Portugal_2009" 68 "Portugal_2015" ///
									 69 "Sweden_1998" 70 "Sweden_2002" 71 "Sweden_2006" 72 "Sweden_2014" ///
									 73 "Germany_1998"
					
label values unified_countrysurveyFE unified_countrysurveyFE 						
					
replace unified_countrysurveyFE = 1 if cses_countryelection_FE == 3 //* Australia 96									 
replace unified_countrysurveyFE = 2 if cses_countryelection_FE == 4 //* Australia 04							
replace unified_countrysurveyFE = 3 if cses_countryelection_FE == 5 //* Australia 07	
replace unified_countrysurveyFE = 4 if cses_countryelection_FE == 6 //* Australia 13	
replace unified_countrysurveyFE = 5 if cses_countryelection_FE == 7 //* Austria 08									 
replace unified_countrysurveyFE = 6 if cses_countryelection_FE == 8 //* Austria 13							
replace unified_countrysurveyFE = 7 if cses_countryelection_FE == 9 //* Flanders 99	
replace unified_countrysurveyFE = 8 if cses_countryelection_FE == 10 //* Wallonia 99
replace unified_countrysurveyFE = 9 if cses_countryelection_FE == 11 //* Belgium 03									 
replace unified_countrysurveyFE = 10 if cses_countryelection_FE == 20 //* Canada 97 							
replace unified_countrysurveyFE = 11 if cses_countryelection_FE == 21 //* Canada 04	
replace unified_countrysurveyFE = 12 if cses_countryelection_FE == 22 //* Canada 08
replace unified_countrysurveyFE = 13 if cses_countryelection_FE == 23 //* Canada 11									 
replace unified_countrysurveyFE = 14 if cses_countryelection_FE == 24 //* Canada 15							
replace unified_countrysurveyFE = 15 if cses_countryelection_FE == 25 //* Switz 99	
replace unified_countrysurveyFE = 16 if cses_countryelection_FE == 26 //* Switz 03
replace unified_countrysurveyFE = 17 if cses_countryelection_FE == 27 //* Switz 07									 
replace unified_countrysurveyFE = 18 if cses_countryelection_FE == 28 //* Switz 11							
replace unified_countrysurveyFE = 19 if cses_countryelection_FE == 37 //* Germany 02	
replace unified_countrysurveyFE = 20 if cses_countryelection_FE == 38 //* Germany 02b
replace unified_countrysurveyFE = 21 if cses_countryelection_FE == 40 //* Germany 2005									 
replace unified_countrysurveyFE = 22 if cses_countryelection_FE == 41 //* Germany 2009							
replace unified_countrysurveyFE = 23 if cses_countryelection_FE == 42 //* Germany 2013	
replace unified_countrysurveyFE = 24 if cses_countryelection_FE == 43 //* Denmark 1998
replace unified_countrysurveyFE = 25 if cses_countryelection_FE == 44 //* Denmark 2001									 
replace unified_countrysurveyFE = 26 if cses_countryelection_FE == 45 //* Denmark 2007							
replace unified_countrysurveyFE = 27 if cses_countryelection_FE == 46 //* Spain 1996 	
replace unified_countrysurveyFE = 28 if cses_countryelection_FE == 47 //* Spain 2000
replace unified_countrysurveyFE = 29 if cses_countryelection_FE == 48 //* Spain 2004									 
replace unified_countrysurveyFE = 30 if cses_countryelection_FE == 49 //* Spain 2008							
replace unified_countrysurveyFE = 31 if cses_countryelection_FE == 51 //* Finland 2003	
replace unified_countrysurveyFE = 32 if cses_countryelection_FE == 52 //* Finland 2007
replace unified_countrysurveyFE = 33 if cses_countryelection_FE == 53 //* Finland 2011									 
replace unified_countrysurveyFE = 34 if cses_countryelection_FE == 54 //* Finland 2015							
replace unified_countrysurveyFE = 35 if cses_countryelection_FE == 56 //* France 2007	
replace unified_countrysurveyFE = 36 if cses_countryelection_FE == 58 //* Britain 1997
replace unified_countrysurveyFE = 37 if cses_countryelection_FE == 59 //* Britain 2005									 
replace unified_countrysurveyFE = 38 if cses_countryelection_FE == 60 //* Britain 2015							
replace unified_countrysurveyFE = 39 if cses_countryelection_FE == 61 //* Greece 2009	
replace unified_countrysurveyFE = 40 if cses_countryelection_FE == 62 //* Greece 2012
replace unified_countrysurveyFE = 41 if cses_countryelection_FE == 63 //* Greece 2015									 
replace unified_countrysurveyFE = 42 if cses_countryelection_FE == 72 //* Ireland 2002							
replace unified_countrysurveyFE = 43 if cses_countryelection_FE == 73 //* Ireland 2007	
replace unified_countrysurveyFE = 44 if cses_countryelection_FE == 74 //* Ireland 2011
replace unified_countrysurveyFE = 45 if cses_countryelection_FE == 75 //* Iceland 1999									 
replace unified_countrysurveyFE = 46 if cses_countryelection_FE == 76 //* Iceland 2003							
replace unified_countrysurveyFE = 47 if cses_countryelection_FE == 77 //* Iceland 2007	
replace unified_countrysurveyFE = 48 if cses_countryelection_FE == 78 //* Iceland 2009
replace unified_countrysurveyFE = 49 if cses_countryelection_FE == 79 //* Iceland 2013									 
replace unified_countrysurveyFE = 50 if cses_countryelection_FE == 84 //* Italy 2006							
replace unified_countrysurveyFE = 51 if cses_countryelection_FE == 107 //* Netherlands 1998	
replace unified_countrysurveyFE = 52 if cses_countryelection_FE == 108 //* Netherlands 2002
replace unified_countrysurveyFE = 53 if cses_countryelection_FE == 109 //* Netherlands 2006									 
replace unified_countrysurveyFE = 54 if cses_countryelection_FE == 110 //* Netherlands 2010							
replace unified_countrysurveyFE = 55 if cses_countryelection_FE == 111 //* Norway 1997	
replace unified_countrysurveyFE = 56 if cses_countryelection_FE == 112 //* Norway 2001
replace unified_countrysurveyFE = 57 if cses_countryelection_FE == 113 //* Norway 2005									 
replace unified_countrysurveyFE = 58 if cses_countryelection_FE == 114 //* Norway 2009							
replace unified_countrysurveyFE = 59 if cses_countryelection_FE == 115 //* Norway 2013	
replace unified_countrysurveyFE = 60 if cses_countryelection_FE == 116 //* NZ 1996
replace unified_countrysurveyFE = 61 if cses_countryelection_FE == 117 //* NZ 2002									 
replace unified_countrysurveyFE = 62 if cses_countryelection_FE == 118 //* NZ 2008							
replace unified_countrysurveyFE = 63 if cses_countryelection_FE == 119 //* NZ 2011	
replace unified_countrysurveyFE = 64 if cses_countryelection_FE == 120 //* NZ 2014
replace unified_countrysurveyFE = 65 if cses_countryelection_FE == 134 //* Portugal 2002									 
replace unified_countrysurveyFE = 66 if cses_countryelection_FE == 135 //* Portugal 2005							
replace unified_countrysurveyFE = 67 if cses_countryelection_FE == 136 //* Portugal 2009	
replace unified_countrysurveyFE = 68 if cses_countryelection_FE == 137 //* Portugal 2015
replace unified_countrysurveyFE = 69 if cses_countryelection_FE == 153 //* Sweden 1998									 
replace unified_countrysurveyFE = 70 if cses_countryelection_FE == 154 //* Sweden 2002							
replace unified_countrysurveyFE = 71 if cses_countryelection_FE == 155 //* Sweden 2006	
replace unified_countrysurveyFE = 72 if cses_countryelection_FE == 156 //* Sweden 2014
replace unified_countrysurveyFE = 73 if cses_countryelection_FE == 39 //* Germany 1998


gen unified_votechoice =.
label variable unified_votechoice "Vote Choice (Party Categories - 6)"
label define unified_votechoice 1 "Mainstream Incumbent Party " 2 "Mainstream Opposition Party" 3 "Complementary Party" 4 "Halfway-House Party" 5 "Antisystem Party" 6 "Abstain"
label values unified_votechoice unified_votechoice				
					
replace unified_votechoice = 1 if cses_votechoice == 1
replace unified_votechoice = 2 if cses_votechoice == 2
replace unified_votechoice = 3 if cses_votechoice == 3
replace unified_votechoice = 4 if cses_votechoice == 4
replace unified_votechoice = 5 if cses_votechoice == 5
replace unified_votechoice = 6 if cses_votechoice == 6

gen unified_votechoice2 =.
label variable unified_votechoice2 "Vote Choice (Party Categories - 5)"
label define unified_votechoice2 1 "Mainstream Party" 2 "Complementary Party" 3 "Halfway-House Party" 4 "Antisystem Party" 5 "Abstain"
label values unified_votechoice2 unified_votechoice2				
					
replace unified_votechoice2 = 1 if cses_reduced_votechoice1 == 1
replace unified_votechoice2 = 2 if cses_reduced_votechoice1 == 2
replace unified_votechoice2 = 3 if cses_reduced_votechoice1 == 3
replace unified_votechoice2 = 4 if cses_reduced_votechoice1 == 4
replace unified_votechoice2 = 5 if cses_reduced_votechoice1 == 5


gen unified_partisanship =.
label variable unified_partisanship "Partisanship (Party Categories - 6)"
label define unified_partisanship 1 "Mainstream Incumbent Party " 2 "Mainstream Opposition Party" 3 "Complementary Party" 4 "Halfway-House Party" 5 "Antisystem Party" 6 "No PID"
label values unified_partisanship unified_partisanship				
					
replace unified_partisanship = 1 if cses_PID_votechoice == 1
replace unified_partisanship = 2 if cses_PID_votechoice == 2
replace unified_partisanship = 3 if cses_PID_votechoice == 3
replace unified_partisanship = 4 if cses_PID_votechoice == 4
replace unified_partisanship = 5 if cses_PID_votechoice == 5
replace unified_partisanship = 6 if cses_PID_votechoice == 6

gen unified_partisanship2 =.
label variable unified_partisanship2 "Partisanship (Party Categories - 5)"
label define unified_partisanship2 1 "Mainstream Party" 2 "Complementary Party" 3 "Halfway-House Party" 4 "Antisystem Party" 5 "No PID"
label values unified_partisanship2 unified_partisanship2				
					
replace unified_partisanship2 = 1 if cses_PID_reducedvotechoice == 1
replace unified_partisanship2 = 2 if cses_PID_reducedvotechoice == 2
replace unified_partisanship2 = 3 if cses_PID_reducedvotechoice == 3
replace unified_partisanship2 = 4 if cses_PID_reducedvotechoice == 4
replace unified_partisanship2 = 5 if cses_PID_reducedvotechoice == 5



gen unified_MSpolarisation = .
replace unified_MSpolarisation = cses_percepolar_MS 
label variable unified_MSpolarisation "How much L-R ideological polarisation among mainstream parties does respondent perceive? (Alt.Dalton Method)"

gen unified_MSmaxrange =.
replace unified_MSmaxrange = cses_widestms_range 
label variable unified_MSmaxrange "How much L-R ideological polarisation between the two most radical left/right-wing mainstream parties does respondent perceive? (Simple Range Method)"

gen unified_MSbigrange =.
replace unified_MSbigrange = cses_twolargeparty_range 
label variable unified_MSbigrange "How much L-R ideological polarisation between the two largest left/right-wing mainstream parties does respondent perceive? (Simple Range Method)"

gen unified_gender =.
replace unified_gender = 1 if cses_gender == 1
replace unified_gender = 0 if cses_gender == 0
label define unified_gender 1 "Female" 0 "Male"
label values unified_gender gender
label variable unified_gender "Respondent's gender"

gen unified_age =.
replace unified_age = cses_age 
label variable unified_age "How old is respondent? (years)"

gen unified_age4cat =.
replace unified_age4cat = cses_age_4cat 
label variable unified_age4cat "How old is respondent (years, 4 categories)"
label define unified_age4cat 1 "18-24" 2 "25-44" 3 "45-64" 4 "65+"
label values unified_age4cat unified_age4cat

gen unified_education3cat =.
replace unified_education3cat = 0 if cses_education_3cat == 0 
replace unified_education3cat = 1 if cses_education_3cat == 1 
replace unified_education3cat = 2 if cses_education_3cat == 2 
label variable unified_education3cat "When did respondent finish full-time education? (3 categories)"
label define unified_education3cat 0 "Left school pre-16 (i.e. to secondary)" 1 "Left between 16-19(i.e some post-secondary, no degree)"  2 "Left school post-19 (i.e. degree holder)", replace
label values unified_education3cat unified_education3cat

gen unified_educationdegree =.
replace unified_educationdegree = 1 if cses_education_degree == 1
replace unified_educationdegree = 0 if cses_education_degree == 0
label variable unified_educationdegree "Does respondent have a university degree? (dummy var)"
label define unified_educationdegree 1 "Degree-holder" 0 "Non degree-holder"
label values unified_educationdegree unified_educationdegree

gen unified_selfradical =.
replace unified_selfradical = cses_self_rad 
label variable unified_selfradical "Respondent distance from ideological centre (0-5: L-R position rescaled as distance from central value)"
label define unified_selfradical 0 "Centrist Voter" 5 "Most Radical Voter"
label values unified_selfradical unified_selfradical

gen unified_selfradical2 =.
replace unified_selfradical2 = cses_self_rad2
label variable unified_selfradical2 "Respondent distance from ideological centre (as above, but DK = Centre)"
label define unified_selfradical2 0 "Centrist Voter" 5 "Most Radical Voter"
label values unified_selfradical2 unified_selfradical2


//* Create standardised variables of economy and political satisfaction.

gen unified_econpos =.
replace  unified_econpos = 1 if cses_econpos_5cat == 1 
replace  unified_econpos = 2 if cses_econpos_5cat == 2  
replace  unified_econpos = 3 if cses_econpos_5cat == 3 
replace  unified_econpos = 4 if cses_econpos_5cat == 4 
replace  unified_econpos = 5 if cses_econpos_5cat == 5 
label variable unified_econpos "Respondent evaluation of economic change in their country"
label define unified_econpos 1 "Economy got a lot worse" 2 "Economy got a bit worse" 3 "No change" 4 "Economy got a bit better" 5 "Economy got a lot better"
label values unified_econpos  unified_econpos 


order unified_respondentID unified_surveywave unified_countryFE unified_countrysurveyFE unified_votechoice unified_votechoice2 ///
unified_partisanship unified_partisanship2 unified_MSpolarisation unified_MSmaxrange unified_MSbigrange unified_gender ///
unified_age unified_age4cat unified_education3cat  unified_educationdegree unified_selfradical unified_selfradical2 ///
unified_econpos , before(master_id)



**************************************************************************************************************************************************

*** Adding Aggregate Variables ***

save "$data2\CSESedit.dta", replace
clear
use "$data2\pwt91.dta" //* Penn World Table v9.1 (Downloaded: 04/11/19).

keep countrycode country year pop rgdpna 
encode country, gen(country_n) 

* Convert back to raw figures

replace pop = pop * 1000000
replace rgdpna = rgdpna * 1000000  //* RGDPNA = Real GDP at constant national prices (in Millions of 2005 US Dollars). Best for studies comparing growth rates across countries over time. 

* Make per capita 
gen PC_rgdpna = (rgdpna/pop) 
bysort country_n (year) : gen lag_rgdpnaPC =  PC_rgdpna[_n-1] //* Lagged GDP per Capita 

* Lagged Per Capita Growth Rates *
bysort country_n (year) : gen lag2GR_rgdpnaPC = ((PC_rgdpna[_n-1] - PC_rgdpna[_n-2])/ PC_rgdpna[_n-2]) * 100 //* Lagged GDP per Capita Annual % Growth Rate (i.e. 2009 lagged GDP growth = growth between end of 2007 and end of 2008)

* If missing missing data, use most recently available GDP growth (only affects 11 elections held in 1950/51).

bysort country_n (year) : replace lag2GR_rgdpnaPC = ((PC_rgdpna[_n] - PC_rgdpna[_n-1])/ PC_rgdpna[_n-1]) * 100 if lag2GR_rgdpnaPC ==. 
bysort country_n (year) : replace lag_rgdpnaPC = lag_rgdpnaPC[_n +1] if lag_rgdpnaPC ==.
bysort country_n (year) : replace lag2GR_rgdpnaPC = lag2GR_rgdpnaPC[_n +1] if lag2GR_rgdpnaPC ==.

gen unified_countrysurveyFE =.

replace unified_countrysurveyFE = 1 if country_n == 9 & year == 1996 //* Australia 96									 
replace unified_countrysurveyFE = 2 if country_n == 9 & year == 2004 //* Australia 04							
replace unified_countrysurveyFE = 3 if country_n == 9 & year == 2007 //* Australia 07	(45080.57 + 44278.41 + 2.089023)
replace unified_countrysurveyFE = 4 if country_n == 9 & year == 2013 //* Australia 13	
replace unified_countrysurveyFE = 5 if country_n == 10 & year == 2008 //* Austria 08									 
replace unified_countrysurveyFE = 6 if country_n == 10 & year == 2013 //* Austria 13							
replace unified_countrysurveyFE = 7 if country_n == 17 & year == 1999  //* Flanders 99	
replace unified_countrysurveyFE = 8 if country_n == 17 & year == 1999 //* Wallonia 99
replace unified_countrysurveyFE = 9 if country_n == 17 & year == 2003 //* Belgium 03									 
replace unified_countrysurveyFE = 10 if country_n == 34 & year == 1997 //* Canada 97  	 (34170.29	33078.74	.6092162)
replace unified_countrysurveyFE = 11 if country_n == 34 & year == 2004 //* Canada 04	
replace unified_countrysurveyFE = 12 if country_n == 34 & year == 2008 //* Canada 08
replace unified_countrysurveyFE = 13 if country_n == 34 & year == 2011 //* Canada 11									 
replace unified_countrysurveyFE = 14 if country_n == 34 & year == 2015 //* Canada 15							
replace unified_countrysurveyFE = 15 if country_n == 159 & year == 1999 //* Switz 99	
replace unified_countrysurveyFE = 16 if country_n == 159 & year == 2003 //* Switz 03
replace unified_countrysurveyFE = 17 if country_n == 159 & year == 2007 //* Switz 07									 
replace unified_countrysurveyFE = 18 if country_n == 159 & year == 2011 //* Switz 11							
replace unified_countrysurveyFE = 19 if country_n == 69 & year == 2002 //* Germany 02	
replace unified_countrysurveyFE = 20 if country_n == 69 & year == 2002 //* Germany 02b
replace unified_countrysurveyFE = 21 if country_n == 69 & year == 2005 //* Germany 2005									 
replace unified_countrysurveyFE = 22 if country_n == 69 & year == 2009 //* Germany 2009							
replace unified_countrysurveyFE = 23 if country_n == 69 & year == 2013 //* Germany 2013	
replace unified_countrysurveyFE = 24 if country_n == 52 & year == 1998 //* Denmark 1998
replace unified_countrysurveyFE = 25 if country_n == 52 & year == 2001 //* Denmark 2001									 
replace unified_countrysurveyFE = 26 if country_n == 52 & year == 2007 //* Denmark 2007							
replace unified_countrysurveyFE = 27 if country_n == 152 & year == 1996 //* Spain 1996 	
replace unified_countrysurveyFE = 28 if country_n == 152 & year == 2000 //* Spain 2000
replace unified_countrysurveyFE = 29 if country_n == 152 & year == 2004 //* Spain 2004									 
replace unified_countrysurveyFE = 30 if country_n == 152 & year == 2008 //* Spain 2008							
replace unified_countrysurveyFE = 31 if country_n == 64 & year == 2003 //* Finland 2003	
replace unified_countrysurveyFE = 32 if country_n == 64 & year == 2007 //* Finland 2007
replace unified_countrysurveyFE = 33 if country_n == 64 & year == 2011 //* Finland 2011									 
replace unified_countrysurveyFE = 34 if country_n == 64 & year == 2015 //* Finland 2015	 (37455.55	37557.46	-1.052172)
replace unified_countrysurveyFE = 35 if country_n == 65 & year == 2007 //* France 2007	
replace unified_countrysurveyFE = 36 if country_n == 174 & year == 1997 //* Britain 1997
replace unified_countrysurveyFE = 37 if country_n == 174 & year == 2005 //* Britain 2005									 
replace unified_countrysurveyFE = 38 if country_n == 174 & year == 2015 //* Britain 2015							
replace unified_countrysurveyFE = 39 if country_n == 71 & year == 2009 //* Greece 2009	
replace unified_countrysurveyFE = 40 if country_n == 71 & year == 2012 //* Greece 2012
replace unified_countrysurveyFE = 41 if country_n == 71 & year == 2015 //* Greece 2015									 
replace unified_countrysurveyFE = 42 if country_n == 84 & year == 2002 //* Ireland 2002							
replace unified_countrysurveyFE = 43 if country_n == 84 & year == 2007 //* Ireland 2007	
replace unified_countrysurveyFE = 44 if country_n == 84 & year == 2011 //* Ireland 2011
replace unified_countrysurveyFE = 45 if country_n == 79 & year == 1999 //* Iceland 1999									 
replace unified_countrysurveyFE = 46 if country_n == 79 & year == 2003 //* Iceland 2003							
replace unified_countrysurveyFE = 47 if country_n == 79 & year == 2007 //* Iceland 2007	
replace unified_countrysurveyFE = 48 if country_n == 79 & year == 2009 //* Iceland 2009
replace unified_countrysurveyFE = 49 if country_n == 79 & year == 2013 //* Iceland 2013									 
replace unified_countrysurveyFE = 50 if country_n == 86 & year == 2006 //* Italy 2006							
replace unified_countrysurveyFE = 51 if country_n == 118 & year == 1998 //* Netherlands 1998	
replace unified_countrysurveyFE = 52 if country_n == 118 & year == 2002 //* Netherlands 2002
replace unified_countrysurveyFE = 53 if country_n == 118 & year == 2006 //* Netherlands 2006									 
replace unified_countrysurveyFE = 54 if country_n == 118 & year == 2010 //* Netherlands 2010							
replace unified_countrysurveyFE = 55 if country_n == 124 & year == 1997 //* Norway 1997	
replace unified_countrysurveyFE = 56 if country_n == 124 & year == 2001 //* Norway 2001
replace unified_countrysurveyFE = 57 if country_n == 124 & year == 2005 //* Norway 2005									 
replace unified_countrysurveyFE = 58 if country_n == 124 & year == 2009 //* Norway 2009							
replace unified_countrysurveyFE = 59 if country_n == 124 & year == 2013 //* Norway 2013	
replace unified_countrysurveyFE = 60 if country_n == 119 & year == 1996 //* NZ 1996
replace unified_countrysurveyFE = 61 if country_n == 119 & year == 2002 //* NZ 2002									 
replace unified_countrysurveyFE = 62 if country_n == 119 & year == 2008 //* NZ 2008							
replace unified_countrysurveyFE = 63 if country_n == 119 & year == 2011 //* NZ 2011	
replace unified_countrysurveyFE = 64 if country_n == 119 & year == 2014 //* NZ 2014  (33462.94	32639.66	.9272878
replace unified_countrysurveyFE = 65 if country_n == 132 & year == 2002 //* Portugal 2002									 
replace unified_countrysurveyFE = 66 if country_n == 132 & year == 2005 //* Portugal 2005							
replace unified_countrysurveyFE = 67 if country_n == 132 & year == 2009 //* Portugal 2009	
replace unified_countrysurveyFE = 68 if country_n == 132 & year == 2015 //* Portugal 2015
replace unified_countrysurveyFE = 69 if country_n == 158 & year == 1998 //* Sweden 1998									 
replace unified_countrysurveyFE = 70 if country_n == 158 & year == 2002 //* Sweden 2002							
replace unified_countrysurveyFE = 71 if country_n == 158 & year == 2006 //* Sweden 2006	
replace unified_countrysurveyFE = 72 if country_n == 158 & year == 2014 //* Sweden 2014 (42815.7	42051.65	.455629)
replace unified_countrysurveyFE = 73 if country_n == 69 & year == 1998 //* Germany 1998 (35769.52	35074.89	1.757323)

drop if unified_ ==.

save "$data2\EconData_Mergable.dta", replace
clear

use "$data2\CSESedit.dta", clear

merge m:1 unified_countrysurveyFE using "$data2\EconData_Mergable.dta"


//* Use values for Wallonia (1999), Germany (2002), Sweden (2014), and Wallonia (2014) on Flanders (1999), Germany (2002b), Sweden (2014ees) and Flanders(2014)

replace year  = 1999              if unified_countrysurveyFE == 7
replace pop =  10255160            if unified_countrysurveyFE == 7
replace rgdpna =  342647111680             if unified_countrysurveyFE == 7
replace PC_rgdpna =  33412.16796875             if unified_countrysurveyFE == 7
replace lag_rgdpnaPC = 32318.8359375              if unified_countrysurveyFE == 7
replace lag2GR_rgdpnaPC =  1.84070658683776856             if unified_countrysurveyFE == 7


replace year  =  2002             if unified_countrysurveyFE == 19
replace pop =  81611872             if unified_countrysurveyFE == 19
replace rgdpna =   3113083207680            if unified_countrysurveyFE == 19
replace PC_rgdpna =  38144.98046875             if unified_countrysurveyFE == 19
replace lag_rgdpnaPC =  38180.546875             if unified_countrysurveyFE == 19
replace lag2GR_rgdpnaPC= 1.63547921180725098               if unified_countrysurveyFE == 19


replace year  =   2014            if unified_countrysurveyFE == 72
replace pop =   9689376            if unified_countrysurveyFE == 72
replace rgdpna =  414857428992             if unified_countrysurveyFE == 72
replace PC_rgdpna =  42815.703125             if unified_countrysurveyFE == 72
replace lag_rgdpnaPC = 42051.6484375              if unified_countrysurveyFE == 72
replace lag2GR_rgdpnaPC =  .455628961324691773             if unified_countrysurveyFE == 72


replace year  =  2014             if unified_countrysurveyFE == 74
replace pop = 11219161              if unified_countrysurveyFE == 74
replace rgdpna =   431667118080            if unified_countrysurveyFE == 74
replace PC_rgdpna =  38475.8828125             if unified_countrysurveyFE == 74
replace lag_rgdpnaPC =  38229.63671875             if unified_countrysurveyFE == 74
replace lag2GR_rgdpnaPC =  -.409989655017852783             if unified_countrysurveyFE == 74


save "$data2\CSESedit.dta", replace
clear

use "$data2\MPDataset_MPDS2019a_stata14.dta" //* Manifesto Research Project (Downloaded: 04/11/19).


 * For Norway 1989 (no total number of quasi-statements are available) use party averages for the country instead * 
 
 replace total = 1365 if party == 12810 & total ==.
 replace total = 1018 if party == 12620 & total ==.
 replace total = 1255 if party == 12320 & total ==.
 replace total =  948 if party == 12520 & total ==.
 replace total = 1469 if party == 12221 & total ==.
 replace total = 1520 if party == 12951 & total ==.
 replace total = 1018 if party == 12420 & total ==.
 
 * Drop non-featured countries *
 
 keep if inrange(country,11,15) | inrange(country,21,23) | inrange(country,31,35) | inrange(country,41,43) | country == 51 | country == 53 | country == 54 | inrange(country,62,64)
 
 * Generate Year *
 
gen yr = yofd(edate)
order yr, after(edate)

 * Generate relation to system *
 
 gen type =.
 label variable type "Relation to the System"
 label define type 1 "Mainstream" 2 "Complementary Party" 3 "Half-Way House" 4 "Anti-System" 
 label values type type
 
 order type, after(party)
 

 ******* AUSTRALIA **********
 
  replace type = 4 if party == 63110 & yr <= 2007 //* Australian Greens
  replace type = 2 if party == 63110 & yr == 2010
  replace type = 1 if party == 63110 & yr >  2010
 
  replace type = 1 if party == 63320 //* Australian Labor Party
 
  replace type = 1 if party == 63810 //* Country / National Party
 
  replace type = 1 if party == 63622 //* Country Liberal Party
 
  replace type = 1 if party == 63620 //* Liberal Party of Australia
 
  replace type = 1 if party == 63621 //* Liberal National Party of Queensland

  replace type = 4 if party == 63710 //* Katter's Australian Party
 
  replace type = 2 if party == 63321 //* Australian Democrats
 
  replace type = 2 if party == 63330 //* Anti-Communist LP / Democratic Labor Party
 
  replace type = 2 if party == 63410 //* Palmer UTD
  
  replace type = 2 if party == 63901 //* Nick Xenophon Team
  
  
 ******* AUSTRIA **********
  
  replace type = 4 if party == 42110 & yr <= 1999 //* The Greens 
  replace type = 2 if party == 42110 & yr >= 2002
 
  replace type = 2 if party == 42220 & yr == 1945 //* Austrian Communist Party
  replace type = 4 if party == 42220 & yr >= 1949
 
  replace type = 2 if party == 42320 & yr == 1945 //* Social Democratic Party
  replace type = 1 if party == 42320 & yr >= 1949
 
  replace type = 4 if party == 42420 & yr <= 1956  //* Austrian Freedom Party
  replace type = 3 if party == 42420 & inrange(yr,1959,1970)
  replace type = 1 if party == 42420 & inrange(yr,1971,1983)
  replace type = 3 if party == 42420 & yr == 1986
  replace type = 4 if party == 42420 & inrange(yr,1990,2001)
  replace type = 3 if party == 42420 & yr == 2002
  replace type = 4 if party == 42420 & yr >= 2006
 
  replace type = 2 if party == 42421 & yr <  2008 //* Liberal Forum
  replace type = 1 if party == 42421 & yr >= 2008
 
  replace type = 2 if party == 42430 //* NEOS / New Austria (c)
 
  replace type = 2 if party == 42520 & yr == 1945 //* Austrian People's Party
  replace type = 1 if party == 42520 & yr >= 1949
 
  replace type = 3 if party == 42710 //* BZO / Alliance for the Future of Austria
 
  replace type = 4 if party == 42951 //* Team Stronach
 
  replace type = 2 if party == 42120 //* Peter Pilz List
 
 
 ********** BELGIUM **********
 
  replace type = 4 if party == 21111 & yr  < 1995  //* ECOLO (Wallonia Greens)
  replace type = 2 if party == 21111 & inrange(yr,1995,1999)
  replace type = 1 if party == 21111 & yr >= 2003
 
  replace type = 4 if party == 21112 & yr  < 1995 //* AGALEV (Flemish Greens)
  replace type = 2 if party == 21112 & inrange(yr,1995,1999)
  replace type = 1 if party == 21112 & yr >= 2003

  replace type = 1 if party == 21320 //* Belgian Socialist Party
 
  replace type = 1 if party == 21321 //* Socialist Party Flanders
  replace type = 1 if party == 21221 & inrange(yr,2003,2007) //* Socialist Party (Flanders)
 
  replace type = 1 if party == 21322 //* Socialist Party Wallonia
 
  replace type = 1 if party == 21520 //* Christian Democratic Party of Belgium
 
  replace type = 1 if party == 21522 //* Christian Social Party (Wallonia)
  replace type = 1 if party == 21330 //* SPIRIT / CVV (2007)

  replace type = 1 if party == 21521 //* Christian People's Party (Flanders)
 
  replace type = 1 if party == 21420 //* Liberal Party of Belgium 
  
  replace type = 1 if party == 21421 //* Liberal Party of Flanders
 
  replace type = 1 if party == 21422 //* Liberal Party of Wallonia
  replace type = 1 if party == 21423 //* Liberal Reform Party - Francophone Federation Cartel (1995)
  replace type = 1 if party == 21425 //* Liberal Reform Party - FDF Alliance (1999)
  replace type = 1 if party == 21426 //* Liberal Reform Movement (Wallonia)
 
  replace type = 1 if party == 21424 //* Liberal Party of Brussels
 
  replace type = 4 if party == 21430 //* Dedecker List 
 
  replace type = 4 if party == 21230 //* Worker's Party of Belgium
 
  replace type = 4 if party == 21911 & yr < 1975 //* Walloon Rally
  replace type = 1 if party == 21911 & yr > 1975
 
  replace type = 2 if party == 21912 & yr <= 1977 //* Federal Democratic Front (FDF)
  replace type = 1 if party == 21912 & yr >= 1978
 
  replace type = 4 if party == 21913 & yr <= 1977 //*  People's Union / Flemish Christian Union 
  replace type = 1 if party == 21913 & yr >= 1978
  replace type = 1 if party == 21915 //* People's Union - 21st Century Democracy Cartel (1999)
 
  replace type = 4 if party == 21914 //* Flemish Block    (1978 - 2003)
  replace type = 4 if party == 21917 //* Flemish Interest (2007 -)

  replace type = 4 if party == 21916 & yr <= 2003 //* New Flemish Alliance
  replace type = 3 if party == 21916 & yr >  2004
 
  
 ********** CANADA **********
  
  replace type = 2 if party == 62110 //* Green Party (2008 - )
  
  replace type = 4 if party == 62320 & yr <= 1953 //* CCF / New Democratic Party
  replace type = 2 if party == 62320 & inrange(yr,1957,1972)
  replace type = 1 if party == 62320 & yr >= 1974
  
  replace type = 1 if party == 62620 //* Progressive Conservative Party (1945 - 2000)
  replace type = 1 if party == 62623 //* Conservative Party of Canada (2004 - 2015)
  
  replace type = 1 if party == 62420 //* Liberal Party of Canada

  replace type = 4 if party == 62621 //* Reform Party Party of Canada (1993 - 1997)
  replace type = 4 if party == 62622 //* Reform Alliance (2000)

  replace type = 4 if party == 62901 //* Quebec Bloc

  replace type = 4 if party == 62951 //* Social Credit Party

 
 ********** DENMARK **********
 
  replace type = 2 if party == 13001 //* New Alliance / Liberal Alliance (2007 - 2015)
 
  replace type = 4 if party == 13210 //* Left Socialist Party
 
  replace type = 4 if party == 13220 //* Danish Communist Party
 
  replace type = 4 if party == 13221 //* Common Course

  replace type = 4 if party == 13229 & yr <= 1998 //* Red-Green Unity List / Left Alliance
  replace type = 3 if party == 13229 & yr >  1998
 
  replace type = 4 if party == 13230 & yr <= 1966 //* Socialist People's Party
  replace type = 3 if party == 13230 & inrange(yr,1968,1990)
  replace type = 1 if party == 13230 & yr >= 1994

  replace type = 1 if party == 13320 //* Social Democratic Party
 
  replace type = 2 if party == 13330 & yr <= 1984 //* Centre Democrats
  replace type = 1 if party == 13330 & yr >= 1987
  
  replace type = 1 if party == 13410 //* Danish Social-Liberal Party
 
  replace type = 1 if party == 13420 //* Venstre / Liberals
 
  replace type = 2 if party == 13421 //* Independent's Party / Uafh
  
  replace type = 2 if party == 13422 //* Liberal Centre
  
  replace type = 2 if party == 13520 & yr <= 1984 //* Christian People's / Christian Democrats
  replace type = 1 if party == 13520 & yr >= 1987
  
  replace type = 1 if party == 13620 //* Conservative People's Party
  
  replace type = 4 if party == 13720 & yr <= 2001 //* Danish People's Party
  replace type = 3 if party == 13720 & yr >= 2005
  
  replace type = 4 if party == 13951 //* Progress Party
  
  replace type = 2 if party == 13952 & yr <= 1957 //* Justice Party
  replace type = 1 if party == 13952 & yr >= 1960
  
  replace type = 4 if party == 13953 //* Danish Union
  
  
 ********** FINLAND **********
  
  replace type = 3 if party == 14221 & yr <= 1948 //* Finnish People's Dem Union (Comm)
  replace type = 4 if party == 14221 & inrange(yr,1951,1966)
  replace type = 3 if party == 14221 & yr >= 1970
  
  replace type = 4 if party == 14222 //* Democratic Alternative (Comm)
 
  replace type = 4 if party == 14110 & yr <= 1995 //* Green Union
  replace type = 1 if party == 14110 & yr >= 1999

  replace type = 4 if party == 14223 & yr <= 1995 //* Left Wing Alliance
  replace type = 3 if party == 14223 & inrange(yr,1999,2015)
 
  replace type = 1 if party == 14310 //* Social Democratic League
 
  replace type = 1 if party == 14320 //* Social Democrats
 
  replace type = 1 if party == 14420 //* National Progressive Party / Liberal People's Party
  
  replace type = 2 if party == 14430 //* Young Finnish Party
  
  replace type = 2 if party == 14520 & yr <= 1991 //* Finnish Christian Union / Christ Democrats / Christian League
  replace type = 1 if party == 14520 & yr >= 1995
  
  replace type = 1 if party == 14620 //* National Coalition Party
  
  replace type = 1 if party == 14810 //* Agrarian Union / Centre Party / Finnish Centre
  
  replace type = 4 if party == 14820 & yr <= 1983 //* Finnish Rural Party / True Finns
  replace type = 3 if party == 14820 & inrange(yr,1987,1995)
  replace type = 4 if party == 14820 & yr >= 1999 
  
  replace type = 1 if party == 14901  //* Swedish People's Party
  
  
 ********** FRANCE **********
  
  replace type = 4 if party == 31021 //*  Left Front
  replace type = 4 if party == 31240 //* Indomitable France / Left Party
	
  replace type = 4 if party == 31110 & yr <= 1993 //* Greens - Europe Ecology
  replace type = 1 if party == 31110 & yr >= 1997  
  
  replace type = 1 if party == 31111 //* Generation Ecology (1997)
  
  replace type = 3 if party == 31220 & yr <  1951 //* French Communist Party
  replace type = 4 if party == 31220 & inrange(yr,1951,1967)
  replace type = 3 if party == 31220 & inrange(yr,1968,1981)
  replace type = 4 if party == 31220 & inrange(yr,1986,1997)
  replace type = 3 if party == 31220 & yr == 2002
  replace type = 4 if party == 31220 & yr >= 2007
  
  replace type = 1 if party == 31230 //* Left Radical Party
  
  replace type = 1 if party == 31320 //* Socialist Party
  
  replace type = 1 if party == 31421 //* Radical Party
  
  replace type = 2 if party == 31425 //* En Marche
  
  replace type = 1 if party == 31430 //* Union of Democrats and Independents
 
  replace type = 1 if party == 31521 //* Popular Republican Movement
 
  replace type = 1 if party == 31522 //* Centre Democrats
 
  replace type = 1 if party == 31523 //* Centre, Democracy, and Progress
 
  replace type = 1 if party == 31529 //* Reform Movement
 
  replace type = 4 if party == 31621 & yr <= 1956 //* Rally for French People - Gaullists
  replace type = 1 if party == 31621 & yr >= 1958
 
  replace type = 1 if party == 31622 //* Republican Party of Liberty - National Centre of Independents / UDF
  replace type = 1 if party == 31624 //* UDF
 
  replace type = 4 if party == 31623 //* Poujadists / Union Defence of Traders and Artisans
  
  replace type = 1 if party == 31625 //* Rally for the Republic
 
  replace type = 1 if party == 31626 //* UMP / Union for a Popular Movement
 
  replace type = 1 if party == 31630 //* New Centre
 
  replace type = 1 if party == 31631 //* Centrist Alliance
 
  replace type = 4 if party == 31720 //* National Front
 
 
 ********** GERMANY **********
  
  replace type = 4 if party == 41111 //* The Greens (1983 - 1987)
 
  replace type = 4 if party == 41112 //* Greens / Bundis'90 (1990)
 
  replace type = 2 if party == 41113 & inrange(yr,1994,1998) //* Bundnis'90 / Greens (1994 -)
  replace type = 1 if party == 41113 & yr >= 2002
 
  replace type = 4 if party == 41220 //* Communist Party of Germany
 
  replace type = 4 if party == 41221 //* Party of Democratic Socialism
  replace type = 4 if party == 41222 //* The Left Party of Democratic Socialism
  replace type = 4 if party == 41223 //* The Left
 
  replace type = 2 if party == 41320 & yr <= 1965 //* Social Democratic Party of Germany
  replace type = 1 if party == 41320 & yr >= 1969 
 
  replace type = 2 if party == 41420 & yr <= 1949 //* Free Democratic Party (FDP)
  replace type = 1 if party == 41420 & yr >= 1953
 
  replace type = 2 if party == 41521 & yr <= 1949 //* CDU-CSU
  replace type = 1 if party == 41521 & yr >= 1953
 
  replace type = 2 if party == 41522 & inrange(yr,1949,1953) //* Centre Party

  replace type = 2 if party == 41620 & yr <= 1949 //* German Party
  replace type = 1 if party == 41620 & yr >= 1953

  replace type = 4 if party == 41711 //* Economic Reconstruction League
  
  replace type = 4 if party == 41712 //* German Reich Party
 
  replace type = 4 if party == 41911 //* Bavaria Party
 
  replace type = 2 if party == 41912 //* South Schleswig Party
 
  replace type = 2 if party == 41951 //* German Bloc of Expellees
 
  replace type = 4 if party == 41952 //* Pirate Party
 
  replace type = 4 if party == 41953 //* Alternative for Germany

 
 ********** GREECE **********
  
  replace type = 4 if party == 34210 //* Communist Party of Greece (1974-1985; 1993 - 2015)
 
  replace type = 4 if party == 34211 & yr == 1989 & date == 198906 //* Left and Progress Coalition
  replace type = 3 if party == 34211 & yr == 1989 & date == 198911
  replace type = 3 if party == 34211 & yr == 1990
  replace type = 4 if party == 34211 & yr >= 1993
  replace type = 4 if party == 34020 //* SYRIZA (2004-2012)
  replace type = 4 if party == 34212 & yr == 2012 & date == 201206
  replace type = 4 if party == 34212 & yr == 2015 & date == 201501 //* SYRIZA (2012-15)
  replace type = 3 if party == 34212 & yr == 2015 & date == 201509
  
  replace type = 2 if party == 34213 & yr == 2012 //* Democratic Left
  replace type = 1 if party == 34213 & yr == 2015 
 
  replace type = 4 if party == 34214 //* Popular Unity
 
  replace type = 4 if party == 34313 & yr <= 1981 //* PASOK
  replace type = 1 if party == 34313 & yr >= 1985 
 
  replace type = 4 if party == 34314 //* DIKKI / DemSoc Movement
 
  replace type = 2 if party == 34340 //* Potami / The River
 
  replace type = 2 if party == 34410 //* Union of Centrists
 
  replace type = 1 if party == 34510 //* Centre Union
 
  replace type = 1 if party == 34511 //* New Democracy
 
  replace type = 2 if party == 34512 //* Political Spring
 
  replace type = 4 if party == 34610 //* National Alignment
 
  replace type = 4 if party == 34710 & yr <= 2009 //* Popular Orthodox Rally
  replace type = 3 if party == 34710 & yr >= 2012
 
  replace type = 4 if party == 34720 //* Golden Dawn
 
  replace type = 4 if party == 34730 & yr <= 2015 //* Independent Greeks
  replace type = 3 if party == 34730 & yr == 2015 & pervote == 3.6
 
 
 ********** ICELAND **********
  
  replace type = 4 if party == 15111 & yr <= 2009 //* Left-Green Movement
  replace type = 3 if party == 15111 & yr >= 2013
  
  replace type = 3 if party == 15220 //* People's Alliance / United Socialist Party
  
  replace type = 1 if party == 15320 //* Social Democratic Party
  
  replace type = 2 if party == 15321 //* Social Democratic Federation
  
  replace type = 2 if party == 15322 & yr <= 1971 //* Union of Liberals and Leftists
  replace type = 1 if party == 15322 & yr == 1974
  
  replace type = 2 if party == 15323 //* National Awakening
  
  replace type = 1 if party == 15328 //* The Alliance (SDP Alliance)
  
  replace type = 1 if party == 15420 & inrange(yr,1999,2003) //* Liberal Party
  replace type = 4 if party == 15420 & yr >= 2007
  
  replace type = 4 if party == 15430 //* Citizens' Movement
  
  replace type = 4 if party == 15440 //* Bright Future
  
  replace type = 1 if party == 15620 //* Independence Party
  
  replace type = 4 if party == 15621 //* Citizens Party
  
  replace type = 2 if party == 15450 //* Reform Party
  
  replace type = 2 if party == 15710 //* National Preservation Party
  
  replace type = 1 if party == 15810 //* Progressive Party
  
  replace type = 4 if party == 15951 //* Women's Alliance
  
  replace type = 4 if party == 15952 //* Pirate Party
  
  
 ********** IRELAND **********
  
  replace type = 4 if party == 53021 //* United Left Alliance
  
  replace type = 4 if party == 53110 & yr <= 2002 //* Green Party of Ireland
  replace type = 2 if party == 53110 & yr == 2007
  replace type = 1 if party == 53110 & yr >= 2011
  
  replace type = 4 if party == 53220 //* Workers' Party
  
  replace type = 2 if party == 53221 & yr <= 1992 //* Democratic Left Party
  replace type = 1 if party == 53221 & yr >= 1997
  
  replace type = 4 if party == 53230 //* Socialist Party
  
  replace type = 4 if party == 53231 //* People Before Profit Alliance
  
  replace type = 4 if party == 53240 //* Anti-Austerity Alliance
  
  replace type = 4 if party == 53250 //* Workers and Unemployment Action
  
  replace type = 2 if party == 53320 & yr <= 1948 //* Labour Party
  replace type = 1 if party == 53320 & yr >= 1951
  
  replace type = 1 if party == 53321  //* Social Democrats
  
  replace type = 2 if party == 53420 & yr <= 1989 //* Progressive Democrats
  replace type = 1 if party == 53420 & yr >= 1992
  
  replace type = 2 if party == 53520 & yr <= 1948 //* Fine Gael
  replace type = 1 if party == 53520 & yr >= 1951
  
  replace type = 1 if party == 53620 //* Fianna Fail
  
  replace type = 4 if party == 53714 & yr <= 1948 //* Republican Party
  replace type = 3 if party == 53714 & inrange(yr,1951,1954)
  replace type = 4 if party == 53714 & yr >= 1957
 
  replace type = 4 if party == 53810 & yr <= 1948 //* Party of the Land
  replace type = 3 if party == 53810 & yr >= 1951
 
  replace type = 4 if party == 53951 //* Sinn Fein
  
  replace type = 2 if party == 53981 //* Independent Alliance
 
 
 ********** ITALY **********
  
  replace type = 4 if party == 32021 //* Civil Revolution
  
  replace type = 1 if party == 32022 //* Italy Europe Together 
  
  replace type = 4 if party == 32031 //* Free and Equal
  
  replace type = 1 if party == 32051 //* Popular Civic List 
  
  replace type = 1 if party == 32055 //* Us With Italy
  
  replace type = 1 if party == 32061 //* People of Freedom / Forza Italia
  
  replace type = 1 if party == 32090 //* SVP-PATT
  
  replace type = 4 if party == 32110 & yr <= 1992 //* Green Federation
  replace type = 2 if party == 32110 & yr == 1994
  replace type = 1 if party == 32110 & yr >= 1996
  
  replace type = 1 if party == 32111 //* The Sunflower
  
  replace type = 4 if party == 32210 //* Communist / Proletarian Unity
  
  replace type = 4 if party == 32211 //* Proletarian Democracy
  
  replace type = 4 if party == 32212 & yr <= 1996 //* Communist Refoundation Party
  replace type = 3 if party == 32212 & yr >= 2001
  
  replace type = 3 if party == 32213 //* Party of Italian Communists
  
  replace type = 4 if party == 32220 & yr <= 1976 //* Italian Communist Party
  replace type = 3 if party == 32220 & yr == 1979
  replace type = 4 if party == 32220 & inrange(yr,1983,1987)
  
  replace type = 2 if party == 32220 & yr == 1992 //* Democratic Party of the Left
  replace type = 1 if party == 32220 & yr >= 1994
  
  replace type = 3 if party == 32221 //* Rose in the Fist
  
  replace type = 3 if party == 32230 //* Left Ecology Freedom
  
  replace type = 4 if party == 32310 & inrange(yr,1976,1994) //* Radical Party / Panella List (c)
  replace type = 3 if party == 32310 & yr == 1996
  
  replace type = 4 if party == 32320 & yr <= 1953 //* Italian Socialist Party
  replace type = 2 if party == 32320 & yr == 1958
  replace type = 1 if party == 32320 & yr >= 1963
  replace type = 1 if party == 32322 //* Unified Italian Socialists
  
  replace type = 1 if party == 32321 //* Italian Renewal
  
  replace type = 1 if party == 32329 //* The Olive Tree
  
  replace type = 1 if party == 32330 //* Italian Democratic Socialist Party / Socialist Unity
  
  replace type = 1 if party == 32410 //* Italian Republican Party
  
  replace type = 1 if party == 32420 //* Italian Liberal Party
  
  replace type = 1 if party == 32421 //* The Daisy
  
  replace type = 1 if party == 32440 //* Democratic Party
  
  replace type = 1 if party == 32450 //* Democratic Centre
  
  replace type = 1 if party == 32460 //* Civic Choice
  
  replace type = 1 if party == 32520 //* Christian Democrats / Italian Popualr Party
  
  replace type = 1 if party == 32521 //* Christian Democratic Centre
  
  replace type = 1 if party == 32522 //* The White Flower
  
  replace type = 1 if party == 32528 //* Pact for Italy / Segni
  
  replace type = 2 if party == 32529 & yr == 1994 //* Democratic Alliance (c)
  replace type = 1 if party == 32529 & yr == 1996 //* Democratic Alliance (c)
  
  replace type = 1 if party == 32530 //* Union for Christian and Centre Democrats
  
  replace type = 4 if party == 32610 & yr == 1994 //* Forza Italia
  replace type = 1 if party == 32610 & yr > 1994
  
  replace type = 1 if party == 32629 //* House of Freedom
  
  replace type = 1 if party == 32611 //* New Italian Socialist Party
  
  replace type = 3 if party == 32630 //* Brothers of Italy
  
  replace type = 4 if party == 32640 //* Labour and Freedom List
  
  replace type = 4 if party == 32710 & yr <= 1994 //* Italian Social Movement
  replace type = 3 if party == 32710 & yr >= 1996 //* National Alliance (c)
  
  replace type = 4 if party == 32720 & yr <= 1996 //* Lega Nord
  replace type = 3 if party == 32720 & inrange(yr,2001,2013)
  replace type = 4 if party == 32720 & yr == 2018 
  
  replace type = 2 if party == 32901 //* European Democracy
  
  replace type = 4 if party == 32902 & yr <= 2001 //* Italy of Values
  replace type = 3 if party == 32902 & inrange(yr,2006,2008)
  
  replace type = 1 if party == 32903 //* Aosta Valley Liberty
  
  replace type = 1 if party == 32904 //* South Tyrolean People's Party
  
  replace type = 1 if party == 32906 //* Aosta Valley
  
  replace type = 4 if party == 32951 //* The Network / Movement for Democracy
  
  replace type = 2 if party == 32952 //* Italy in the World
  
  replace type = 1 if party == 32953 //* Popular Democratic Union for Europe
  
  replace type = 1 if party == 32955 //* Union for Prodi
  
  replace type = 4 if party == 32956 //* 5 Star Movement
  
  replace type = 2 if party == 32451 //* More Europe
	
 ********** LUXEMBOURG **********
  
   replace type = 4 if party == 23112 //* Green Alternative (1984-1989)
   replace type = 2 if party == 23113 //* Green Alternative (1994-2013)
  
   replace type = 2 if party == 23111 //* Green Left Ecological Initiative
 
   replace type = 4 if party == 23220 //* Communist Party of Luxembourg
  
   replace type = 4 if party == 23230 //* The Left
  
   replace type = 1 if party == 23320 //* Socialist Workers Party of Luxembourg
   
   replace type = 1 if party == 23420 //* Democratic Party
  
   replace type = 1 if party == 23520 //* Christian Social People's Party
  
   replace type = 4 if party == 23951 //* Alternative Democratic Reform Party
  
  
 ********** MALTA **********
  
  replace type = 1 if party == 54320 //* Labour Party
  
  replace type = 1 if party == 54620 //* Nationalist Party
  
  
 ********** NETHERLANDS **********
  
  replace type = 4 if party == 22110 & yr <= 2002 //* GreenLeft
  replace type = 2 if party == 22110 & yr >= 2003
  
  replace type = 4 if party == 22210 //* Communist Party of Netherlands
  
  replace type = 4 if party == 22220 //* Socialist Party
  
  replace type = 4 if party == 22230 //* Pacifist Socialist Party
  
  replace type = 1 if party == 22310 & yr <= 1977 //* Radical Political Party
  replace type = 4 if party == 22310 & yr >= 1981
  
  replace type = 1 if party == 22320 //* Labour Party
  
  replace type = 4 if party == 22330 & yr == 1967 //* Democrats 66'
  replace type = 3 if party == 22330 & inrange(yr,1971,2012)
  replace type = 1 if party == 22330 & yr >= 2017
  
  replace type = 2 if party == 22420 & yr <= 1948 //* Party for Freedom
  replace type = 1 if party == 22420 & yr >= 1952
  
  replace type = 4 if party == 22321 //* DENK
  
  replace type = 4 if party == 22430 //* Livable Netherlands
  
  replace type = 1 if party == 22521 //* Christian Democratic Appeal
  
  replace type = 1 if party == 22522 //* Catholic People's Party
  
  replace type = 1 if party == 22523 //* Anti-Revolutionary Party
  
  replace type = 2 if party == 22524 //* Democratic Socialists'70
  
  replace type = 1 if party == 22525 //* Christian Historical Union
  
  replace type = 2 if party == 22526 & yr <= 2006 //* Christian Union
  replace type = 1 if party == 22526 & yr >= 2010  
  
  replace type = 4 if party == 22527 //* Reformed Political Party
  
  replace type = 4 if party == 22528 //* Reformed Political Federation
  
  replace type = 4 if party == 22710 //* Centre Party
  
  replace type = 4 if party == 22711 //* Centre Democrats
  
  replace type = 4 if party == 22720 & yr <= 2002 //* Pim Fortuyn List
  replace type = 3 if party == 22720 & yr >= 2003 
  
  replace type = 4 if party == 22722 //* Party for Freedom (c)
  
  replace type = 2 if party == 22951 //* Party for Animals
  
  replace type = 4 if party == 22952 //* Reformed Political Party
  
  replace type = 2 if party == 22953 //* 50+
  
  replace type = 2 if party == 22954 //* General Elderly Alliance
  
  replace type = 2 if party == 22955 //* Union 55+
  
  replace type = 4 if party == 22730 //* Forum for Democracy
  
  
 ********** NEW ZEALAND **********
  
  replace type = 2 if party == 64110 & yr <= 1999 //* Green Party
  replace type = 1 if party == 64110 & yr >= 2002
  
  replace type = 1 if party == 64320 //* NZ Labour Party
  
  replace type = 4 if party == 64321 & yr <= 1993 //* Alliance
  replace type = 2 if party == 64321 & yr >= 1996  
  
  replace type = 4 if party == 64420 & yr <= 2008 //* ACT NZ
  replace type = 3 if party == 64420 & yr >= 2011   
  
  replace type = 2 if party == 64421 & yr <= 2002 //* United Future NZ
  replace type = 1 if party == 64421 & yr >= 2005 
  
  replace type = 1 if party == 64422 //* Anderton Progressives
  
  replace type = 1 if party == 64620 //* NZ National Party
  
  replace type = 4 if party == 64621 & yr <= 1996 //* NZ First Party
  replace type = 3 if party == 64621 & yr >= 1999  
  
  replace type = 1 if party == 64901 //* Maori Party
  
  replace type = 4 if party == 64902 //* Mana Party
  
  replace type = 4 if party == 64951 //* Social Credit 
  
  
 ********** NORWAY **********
  
  replace type = 3 if party == 12220 & yr <= 1945 //* Norwegian Communist Party
  replace type = 4 if party == 12220 & yr >= 1949    
  
  replace type = 4 if party == 12221 & yr <= 1997 //* Socialist Peope's/Left Party
  replace type = 2 if party == 12221 & inrange(yr,2001,2005) 
  replace type = 1 if party == 12221 & yr >= 2009

  replace type = 1 if party == 12320 //* Norwegian Labour Party
  
  replace type = 2 if party == 12410 //* New People's Party
  
  replace type = 1 if party == 12420 //* Liberal Party
  
  replace type = 2 if party == 12520 & yr <= 1961 //* Christian Democrats / Christian People's Party
  replace type = 1 if party == 12520 & yr >= 1965  
  
  replace type = 1 if party == 12620 //* Conservative Party
  
  replace type = 1 if party == 12810 //* Farmer's Party / Centre Party
 
  replace type = 4 if party == 12951 & yr <= 2001 //* Progress Party / Anders Lange
  replace type = 2 if party == 12951 & yr == 2005
  replace type = 1 if party == 12951 & yr >= 2009
  
  replace type = 4 if party == 12110 //* Green Party 
 
 ********** PORTUGAL **********
  
  replace type = 4 if party == 35110  //* Portuguese Green Party
  
  replace type = 4 if party == 35210 //* Popular Democratic Union
 
  replace type = 4 if party == 35211 //* Left Bloc
 
  replace type = 4 if party == 35220 //* Portugal Communist Party
 
  replace type = 4 if party == 35229 //* Unified Democratic Coalition
 
  replace type = 4 if party == 35310 //* Popular Democratic Movement
 
  replace type = 4 if party == 35311 & yr <= 1976 //* Socialist Party
  replace type = 1 if party == 35311 & yr >= 1979
  
  replace type = 2 if party == 35312 & yr <= 1985 //* Democratic Renewal Party
  replace type = 1 if party == 35312 & yr >= 1987
 
  replace type = 4 if party == 35313 & yr <= 1979 //* Popular Democratic Party / SDP
  replace type = 3 if party == 35313 & inrange(yr,1980,1983)
  replace type = 1 if party == 35313 & yr >= 1985
 
  replace type = 4 if party == 35315 //* Democratic Intervention
 
  replace type = 4 if party == 35316 //* Association of Independent SDPs
 
  replace type = 4 if party == 35317 //* Leftwing Union for Socialism
 
  replace type = 4 if party == 35520 & yr <= 1979 //* Social Democratic Center Party
  replace type = 3 if party == 35520 & inrange(yr,1980,1983)
  replace type = 1 if party == 35520 & yr >= 1985
 
  replace type = 4 if party == 35710 & yr < 1983 //* Popular Monarchist Party
  replace type = 3 if party == 35710 & yr >= 1983
 
  replace type = 2 if party == 35951 //* National Soldiarity Party
  
  replace type = 1 if party == 35060 //* Portugal Ahead
 
  replace type = 2 if party == 35120 //* People-Animals-Nature
  
 ********** SPAIN **********
  
  replace type = 4 if party == 33020 //* Popular Unity - Podemos
  replace type = 4 if party == 33025 //* Podemos
  replace type = 4 if party == 33096 //* Podemos
  replace type = 4 if party == 33097 //* In Tide Podemos     
  replace type = 4 if party == 33098 //* Compromise Podemos
  replace type = 4 if party == 33210 //* Podemos
  
  replace type = 3 if party == 33091 //* Future Yes (Basque Nat)
  
  replace type = 4 if party == 33092 //* Amaiur
  
  replace type = 4 if party == 33093 //* EQUO
  
  replace type = 4 if party == 33095 //* Eh Bildu - Basque Country Unite
  
  replace type = 4 if party == 33099 //* Democracy and Freedom
   
  replace type = 4 if party == 33220 & yr <= 1996 //* Communist Party of Spain (c) / United Left
  replace type = 3 if party == 33220 & inrange(yr,2000,2008) //* 2000 alliance with PSOE
  replace type = 4 if party == 33220 & yr >= 2011
  
  replace type = 2 if party == 33320 & yr <= 1982 //* PSOE
  replace type = 1 if party == 33320 & yr >= 1986
  
  replace type = 2 if party == 33420 //* Citizens
  
  replace type = 2 if party == 33430 & yr < 1978 //* Union of Democratic Centre
  replace type = 1 if party == 33430 & yr >= 1979
  
  replace type = 2 if party == 33438 //* Popular Democratic Party
  
  replace type = 2 if party == 33439 //* Liberal Party
  
  replace type = 2 if party == 33440 //* Union, Progress, and Democracy
  
  replace type = 1 if party == 33512 //* Centre Democrats
  
  replace type = 4 if party == 33610 & yr <= 1978 //* Popular Alliance / People's Party
  replace type = 2 if party == 33610 & yr == 1979
  replace type = 1 if party == 33610 & yr >= 1982  
  
  replace type = 2 if party == 33611 & yr <= 1979 //* Convergence and Union
  replace type = 1 if party == 33611 & inrange(yr,1982,2008)
  replace type = 3 if party == 33611 & yr > 2008
  
  replace type = 4 if party == 33905 & yr <= 2004 //* Catalan Republican Left
  replace type = 3 if party == 33905 & yr >= 2008  
  
  replace type = 2 if party == 33612 //* Asturias Forum
  
  replace type = 4 if party == 33906 & yr <= 1979 //* Andalusian Party
  replace type = 3 if party == 33906 & yr >= 1982   
  
  replace type = 4 if party == 33902 & yr <= 1993 //* Basque Nationalist Party
  replace type = 3 if party == 33902 & yr >= 1996  
  
  replace type = 2 if party == 33904 & yr <= 1979 //* Aragonese Party
  replace type = 1 if party == 33904 & yr >= 1981    
  
  replace type = 2 if party == 33901 & yr <= 1982 //* Basque Left
  replace type = 1 if party == 33901 & yr >= 1986   
  
  replace type = 4 if party == 33903 //* Basque Solidarity
  
  replace type = 4 if party == 33911 & yr == 2016 //* Democratic Convergence of Catalonia
  
  replace type = 1 if party == 33907 //* Canarian Coalition
  
  replace type = 4 if party == 33908 & yr <= 2004 //* Galician Nationalist Bloc
  replace type = 3 if party == 33908 & yr >= 2008  
   
  replace type = 4 if party == 33909 & yr <= 2004 //* Aragonist Council
  replace type = 3 if party == 33909 & yr >= 2008     
   
  replace type = 2 if party == 33910 & yr <= 1979 //* Navarrese People's Union
  replace type = 1 if party == 33910 & yr >= 1981    
   
  
   
 ********** SWEDEN **********
  
  replace type = 4 if party == 11110 & yr <= 1998 //* Green Ecology Party
  replace type = 3 if party == 11110 & inrange(yr,2002,2006)
  replace type = 1 if party == 11110 & yr >= 2010  
  
  replace type = 4 if party == 11220 & yr <= 1998 //* Communist Party of Sweden / Left Party
  replace type = 3 if party == 11220 & yr >= 2002  
  
  replace type = 1 if party == 11320 //* Social Democratic Labour Party
  
  replace type = 1 if party == 11420 //* People's Party / Liberals
  
  replace type = 1 if party == 11520 //* Christian Democrats
  
  replace type = 1 if party == 11620 //* Right Party / Moderate Coalition Party
  
  replace type = 4 if party == 11710 //* Sweden Democrats
 
  replace type = 1 if party == 11810 //* Agrarian / Center Party
 
  replace type = 4 if party == 11951 //* New Democracy
 
 
 ********** SWITZERLAND **********
  
  replace type = 2 if party == 43110 //* Green Party
  
  replace type = 2 if party == 43120 //* Green Liberal Party
 
  replace type = 4 if party == 43220 //* Swiss Labour Party
 
  replace type = 1 if party == 43320 //* Social Democratic Paryt of Switzerland
 
  replace type = 4 if party == 43321 //* Independents' Alliance
 
  replace type = 1 if party == 43420 //* Radical Democratic Party / Liberals
 
  replace type = 1 if party == 43520 //* Conservative People's Party

  replace type = 1 if party == 43530 //* Evangelical People's Party
 
  replace type = 2 if party == 43531 //* Liberal Party of Switzerland
 
  replace type = 2 if party == 43540 //* Christian Social Party
 
  replace type = 4 if party == 43710 //* National Action Party
 
  replace type = 4 if party == 43711 //* Federal Democratic Union
 
  replace type = 1 if party == 43810 & yr <= 1995 //* Farmers / Swiss People's Party
  replace type = 3 if party == 43810 & yr >= 1999
  
  replace type = 1 if party == 43811 //* Conservative Democratic Party
 
  replace type = 4 if party == 43901 //* Ticino League
 
  replace type = 4 if party == 43902 //* Geneva Citizens' Movement
 
  replace type = 4 if party == 43951 //* Swiss Motorists Party / Freedom Party
 
 
 ********** UNITED KINGDOM **********
 
  replace type = 4 if party == 51110 //* Green Party
  
  replace type = 4 if party == 51210 //* Sinn Fein
 
  replace type = 1 if party == 51320 //* Labour Party
 
  replace type = 1 if party == 51330 //* Social Democratic Party
 
  replace type = 1 if party == 51340 //* SDLP
  
  replace type = 1 if party == 51420 //* Liberal Party
 
  replace type = 1 if party == 51421 //* Liberal Democratic Party
 
  replace type = 1 if party == 51620 //* Conservative Party
 
  replace type = 1 if party == 51621 //* Ulster Unionist Party
 
  replace type = 4 if party == 51901 //* Plaid Cymru
 
  replace type = 4 if party == 51902 //* Scottish National Party
 
  replace type = 4 if party == 51903 //* Democratic Unionist Party
 
  replace type = 4 if party == 51951 //* UKIP

  
 order rile, after(pervote)
 
  * Drop Wallonia/Flan (1968-) from above
 
 drop if country == 21 & date >= 196803
 

 * Drop (6) instances of missing programmes (1 * Greece 09; 4 * Greece 15b; 1 * Switz 11 - All non-Mainstrream parties)

 drop if pervote == . //* Exclude:  Was in an electoral coalition.
 drop if progtype == 99 //* Exclude: Missing programmes.
 drop if type != 1 //* Exclude: Non-mainstream party.
 
 * Drop unused variables *
 
  drop countryname peruncod partyname oecdmember eumember date partyabbrev parfam coderid manual coderyear ///
  testresult testeditsim voteest presvote absseat totseats datasetorigin corpusversion ///
  planeco markeco welfare intpeace datasetversion id_perm

 * Party Position Generators (from Prosser 2014)
 
gen raw101 = (per101/100)*total
gen raw102 = (per102/100)*total
gen raw103 = (per103/100)*total
gen raw104 = (per104/100)*total
gen raw105 = (per105/100)*total
gen raw106 = (per106/100)*total
gen raw107 = (per107/100)*total
gen raw108 = (per108/100)*total
gen raw109 = (per109/100)*total
gen raw110 = (per110/100)*total
gen raw201 = (per201/100)*total
gen raw202 = (per202/100)*total
gen raw203 = (per203/100)*total
gen raw204 = (per204/100)*total
gen raw301 = (per301/100)*total
gen raw302 = (per302/100)*total
gen raw303 = (per303/100)*total
gen raw304 = (per304/100)*total
gen raw305 = (per305/100)*total
gen raw401 = (per401/100)*total
gen raw402 = (per402/100)*total
gen raw403 = (per403/100)*total
gen raw404 = (per404/100)*total
gen raw405 = (per405/100)*total
gen raw406 = (per406/100)*total
gen raw407 = (per407/100)*total
gen raw408 = (per408/100)*total
gen raw409 = (per409/100)*total
gen raw410 = (per410/100)*total
gen raw411 = (per411/100)*total
gen raw412 = (per412/100)*total
gen raw413 = (per413/100)*total
gen raw414 = (per414/100)*total
gen raw415 = (per415/100)*total
gen raw416 = (per416/100)*total
gen raw501 = (per501/100)*total
gen raw502 = (per502/100)*total
gen raw503 = (per503/100)*total
gen raw504 = (per504/100)*total
gen raw505 = (per505/100)*total
gen raw506 = (per506/100)*total
gen raw507 = (per507/100)*total
gen raw601 = (per601/100)*total
gen raw602 = (per602/100)*total
gen raw603 = (per603/100)*total
gen raw604 = (per604/100)*total
gen raw605 = (per605/100)*total
gen raw606 = (per606/100)*total
gen raw607 = (per607/100)*total
gen raw608 = (per608/100)*total
gen raw701 = (per701/100)*total
gen raw702 = (per702/100)*total
gen raw703 = (per703/100)*total
gen raw704 = (per704/100)*total
gen raw705 = (per705/100)*total
gen raw706 = (per706/100)*total

*The second stage calculates the three scale variables
*gen_lr is the one dimensional general left-right scale
*econ_lr is the economic left-right scale from the two dimensional scale set
*social_lc is the social liberal-conserative scale from the two dimensional scale set

gen gen_lr = log((raw109 + raw401 + raw407 + raw414 + raw505 + raw507 + raw601 + raw603 + raw608 + raw702 + 0.5)/(raw105 + raw106 + raw107 + raw108 + raw202 + raw301 + raw303 + raw403 + raw408 + raw411 + raw412 + raw413 + raw416 + raw501 + raw502 + raw503 + raw504 + raw506 + raw602 + raw604 + raw701 + raw705 + raw706 + 0.5))

gen econ_lr = log((raw401 + raw407 + raw414 + raw505 + raw507 + raw702 + 0.5)/(raw403 + raw411 + raw412 + raw413 + raw503 + raw504 + raw506 + raw701 + 0.5))

gen social_lc = log((raw109 + raw302 + raw305 + raw601 + raw608 + 0.5)/(raw105 + raw106 + raw107 + raw201 + raw202 + raw301 + raw416 + raw501 + raw502 + raw602 + raw607 + raw704 + raw705 + raw706 + 0.5))


*The next step calculates a rescaled version of each scale that in theory approximately ranges from 0-100 (though in practice it doesn't reach either limit) 

egen gen_lr_mean = mean(gen_lr)
gen gen_lr_rescale = (gen_lr - gen_lr_mean + 7)*(100/14)

egen econ_lr_mean = mean(econ_lr)
gen econ_lr_rescale = (econ_lr - econ_lr_mean + 7)*(100/14)

egen social_lc_mean = mean(social_lc)
gen social_lc_rescale = (social_lc - social_lc_mean + 7)*(100/14)

*This step calculates the salience measure outlined in the article for each scale

*The final step deletes the variables generated in order to calculate the scale variables.

drop raw101
drop raw102
drop raw103
drop raw104
drop raw105
drop raw106
drop raw107
drop raw108
drop raw109
drop raw110
drop raw201
drop raw202
drop raw203
drop raw204
drop raw301
drop raw302
drop raw303
drop raw304
drop raw305
drop raw401
drop raw402
drop raw403
drop raw404
drop raw405
drop raw406
drop raw407
drop raw408
drop raw409
drop raw410
drop raw411
drop raw412
drop raw413
drop raw414
drop raw415
drop raw416
drop raw501
drop raw502
drop raw503
drop raw504
drop raw505
drop raw506
drop raw507
drop raw601
drop raw602
drop raw603
drop raw604
drop raw605
drop raw606
drop raw607
drop raw608
drop raw701
drop raw702
drop raw703
drop raw704
drop raw705
drop raw706

drop gen_lr_mean
drop econ_lr_mean 
drop social_lc_mean

  ************************************** Polarisation Scores - Method #1 : Taken from Dalton (2008; 2017) *************************************
  
  
* The polarization index uses the public’s mean perception of a party’s Left-Right position in each nation, weighted by the vote share for each party. Original sampling weights were used for the survey data. In some instances, we estimated party vote shares when parties ran in an electoral alliance, or when electoral returns were incomplete.

* The Polarization Index is calculated as:

*                        PI=SQRT{Σ(party vote sharei)*([party L-R scorei – party system average L-R score]/5)2} 

*                                     	(i represents individual parties).  

*                       Party vote share is calculated as a percentage for parties represented in CSES data. 
*                       Party system average L-R score is weighted by size of each party – i.e. 

*                                              Σ[(party vote sharei*party L-R scorei)/Σ(party vote sharei)]

*                       Where the sum of party vote share falls short of 100 percent in some elections. 
*                       The division by 5 is an arbitrary adjustment to center the index on the 0-10 scale. 
*                       The resulting index has a range from 0 when all parties are located at the same position on the Left-Right scale to 10 when all parties are located at the extreme positions on the CSES Left-Right scale. 


  * Data Prep *
  drop if type !=1
  bysort country edate: gen ranked = _N  
  label variable ranked "Total number of parties ranked by country_election"

  * Step 1: Divide Scores by 10 *
  
  gen GENpartyscore_PROSSER = gen_lr_rescale/10
  gen ECONpartyscore_PROSSER = econ_lr_rescale/10
  gen SOCpartyscore_PROSSER = social_lc_rescale/10
  
  order edate party type pervote GENpartyscore_PROSSER ECONpartyscore_PROSSER SOCpartyscore_PROSSER ranked, after(country)
  
  label variable GENpartyscore_PROSSER "General L-R CMP Policy Dimension from Prosser (2014). Rescaled so 0 = Most LW; 10 = Most RW"
  label variable ECONpartyscore_PROSSER "Economic L-R CMP Policy Dimension from Prosser (2014). Rescaled so 0 = Most LW; 10 = Most RW"
  label variable SOCpartyscore_PROSSER "Social L-R CMP Policy Dimension from Prosser (2014). Rescaled so 0 = Most Liberal; 10 = Most Conservative"

  * Step 2: Divide party scores by their weight (vote share) *
  
  gen GENweight_partyscore = GENpartyscore_PROSSER * pervote
  gen ECONweight_partyscore = ECONpartyscore_PROSSER * pervote
  gen SOCweight_partyscore = SOCpartyscore_PROSSER * pervote
  
  label variable GENweight_partyscore "partyscore * vote"
  label variable ECONweight_partyscore "partyscore * vote"
  label variable SOCweight_partyscore "partyscore * vote"
  
  order GENweight ECONparty ECONweight SOCparty SOCweight, after(GENparty) 
  
  * Step 3: Divide weighted party score by the total vote percentage of all mainstream parties at that election *
  
  bysort country edate: egen PSelectionvote = total(pervote) 
  
  order PSelectionvote,after(pervote)
  label variable PSelectionvote "Total vote share of those PS parties sampled by CMP"
  
  gen ps_GENweight_partyscore = GENweight_partyscore / PSelectionvote 
  gen ps_ECONweight_partyscore = ECONweight_partyscore / PSelectionvote 
  gen ps_SOCweight_partyscore = SOCweight_partyscore / PSelectionvote 
  
  label variable ps_GENweight_partyscore " PS GENweight_partyscore / electionvote"
  label variable ps_ECONweight_partyscore  " PS ECONweight_partyscore / electionvote"
  label variable ps_SOCweight_partyscore "PS SOCweight_partyscore / electionvote"
  
  order GENweight ps_GENweight ECONparty ECONweight ps_ECONweight SOCparty SOCweight ps_SOCweight, after(GENparty) 
  
  * Step 4: Deduct the sum of weighted partyscores(2) from each party's original rawscore"
  
   bysort country edate: egen ps_GENweight_TOTAL = total(ps_GENweight_partyscore) 
   bysort country edate: egen ps_ECONweight_TOTAL = total(ps_ECONweight_partyscore)
   bysort country edate: egen ps_SOCweight_TOTAL = total(ps_SOCweight_partyscore) 

   bysort country edate: gen ps_GEN_distance = GENpartyscore_PROSSER - ps_GENweight_TOTAL  
   bysort country edate: gen ps_ECON_distance = ECONpartyscore_PROSSER - ps_ECONweight_TOTAL 
   bysort country edate: gen ps_SOC_distance = SOCpartyscore_PROSSER - ps_SOCweight_TOTAL
   
   label variable ps_GEN_distance "PS General L-R score minus weighted party system average"
   label variable ps_ECON_distance "PS Economic L-R score minus weighted party system average"
   label variable ps_SOC_distance "PS Social L-R score minus weighted party system average"

   order GENweight ps_GENweight_party ps_GENweight_TOTAL ps_GEN_distance ECONparty ECONweight_party ps_ECONweight_party ps_ECONweight_TOTAL ps_ECON_distance SOCparty SOCweight_party ps_SOCweight_party ps_SOCweight_TOTAL ps_SOC_distance, after(GENparty) 
    
   
   * Step 5: Square the centred distance scores *
    
   gen centred_psGEN_distance = (ps_GEN_distance / 5)^2
   gen centred_psECON_distance = (ps_ECON_distance / 5)^2 
   gen centred_psSOC_distance = (ps_SOC_distance / 5)^2
   
   label variable centred_psGEN "Squared Centred PS Gen Distance"
   label variable centred_psECON "Squared Centred PS Econ Distance"
   label variable centred_psSOC "Squared Centred PS Soc Distance"
   
   order centred_psGEN, after(ps_GEN_distance)
   order centred_psECON, after(ps_ECON_distance)
   order centred_psSOC, after(ps_SOC_distance)
   
   * Step 6: Weight CDS by vote *
   
   gen weighted_psGEN_SCDC = (centred_psGEN * pervote) / PSelectionvote
   gen weighted_psECON_SCDC = (centred_psECON * pervote) / PSelectionvote
   gen weighted_psSOC_SCDC = (centred_psSOC * pervote) / PSelectionvote
    
   label variable weighted_psGEN "Weighted Squared Centred Gen Distance"
   label variable weighted_psECON "Weighted Squared Centred Econ Distance"
   label variable weighted_psSOC "Weighted Squared Centred Soc Distance"   
   
   order weighted_psGEN_SCDC, after(centred_psGEN)
   order weighted_psECON_SCDC, after(centred_psECON)
   order weighted_psSOC_SCDC, after(centred_psSOC)
   
   
   * Step 7: Create Polarisation Index by Summing Weighted CDS scores and then square rooting that sum *
   
   bysort country edate: egen rawpsGEN_Polarisation_DALTON = total(weighted_psGEN) 
   bysort country edate: egen rawpsECON_Polarisation_DALTON = total(weighted_psECON)
   bysort country edate: egen rawpsSOC_Polarisation_DALTON = total(weighted_psSOC) 
   
   gen psGEN_Polarisation_DALTON = sqrt(rawpsGEN_Polarisation_DALTON) 
   gen psECON_Polarisation_DALTON = sqrt(rawpsECON_Polarisation_DALTON) 
   gen psSOC_Polarisation_DALTON = sqrt(rawpsSOC_Polarisation_DALTON) 
   
   order rawpsGEN_Polarisation_DALTON psGEN_Polarisation_DALTON, after(weighted_psGEN)
   order rawpsECON_Polarisation_DALTON psECON_Polarisation_DALTON, after(weighted_psECON)
   order rawpsSOC_Polarisation_DALTON psSOC_Polarisation_DALTON, after(weighted_psSOC)
   
   
   label variable psGEN_Polarisation_DALTON "General Pro-System Polarisation Score for Given National Election, ranging from 0 (no polarisation) to 10 (full polarisation)"
   label variable psECON_Polarisation_DALTON "Economic Pro-System Polarisation Score for Given National Election, ranging from 0 (no polarisation) to 10 (full polarisation)"
   label variable psSOC_Polarisation_DALTON "Social Pro-System Polarisation Score for Given National Election, ranging from 0 (no polarisation) to 10 (full polarisation)"

   ************************************* SIMPLE POLARISATION MEASURE: RANGE **********************************************

 bysort country edate type (pervote): gen count = _n
 bysort country edate type (pervote): gen countZ = _N

 drop if type != 1
 drop if yr < 1950 
 
 **** 1: Range between leftmost and rightmost mainstream parties ****

 bysort country edate type (gen_lr_rescale): gen ps_size = _n

 gen small_large = 1 if ps_size == 1 | ps_size == 2 & countZ == 2 | ps_size == 3 & countZ == 3 | ps_size == 4 & countZ == 4 | ps_size == 5 & countZ == 5 | ps_size == 6 & countZ == 6 | ps_size == 7 & countZ == 7 | ps_size == 8 & countZ == 8 | ps_size == 9 & countZ == 9
 
 bysort country edate type (small_large): gen ps_diverge = gen_lr_res - gen_lr_res[_n-1] if small_large == 1
 gen ms_maxrange = (sqrt(ps_diverge^2))/10
 
 bysort country edate type: replace ms_maxrange = ms_maxrange[_n-1] if ms_maxrange == .
 bysort country edate type: replace ms_maxrange = ms_maxrange[_n-2] if ms_maxrange == .
 bysort country edate type: replace ms_maxrange = ms_maxrange[_n-3] if ms_maxrange == .
 bysort country edate type: replace ms_maxrange = ms_maxrange[_n-4] if ms_maxrange == .
 bysort country edate type: replace ms_maxrange = ms_maxrange[_n-5] if ms_maxrange == .
 bysort country edate type: replace ms_maxrange = ms_maxrange[_n-6] if ms_maxrange == .
 bysort country edate type: replace ms_maxrange = ms_maxrange[_n-7] if ms_maxrange == .
 bysort country edate type: replace ms_maxrange = ms_maxrange[_n+1] if ms_maxrange == .
 
  **** 2: Range between two largest mainstream parties **** 
 
 drop if countZ == 3 & count == 1
 drop if countZ == 4 & inrange(count,1,2)
 drop if countZ == 5 & inrange(count,1,3)
 drop if countZ == 6 & inrange(count,1,4)
 drop if countZ == 7 & inrange(count,1,5)
 drop if countZ == 8 & inrange(count,1,6)
 
 bysort country edate type (pervote): gen countZ_check = _N
 bysort country edate type (pervote): gen totvot = pervote + pervote[_n-1] 
 bysort country edate type (pervote): gen diverge = gen_lr_res - gen_lr_res[_n-1] 
 gen ms_bigrange = (sqrt(diverge^2))/10
 
   * Just keep imported variables *
  
 keep country edate party type psGEN_Polarisation_DALTON psECON_Polarisation_DALTON psSOC_Polarisation_DALTON ms_bigrange ms_maxrange 

   

   * Label Data to Import *
   
collapse psGEN_Polarisation_DALTON psECON_Polarisation_DALTON psSOC_Polarisation_DALTON ms_bigrange ms_maxrange, by(country edate) 

   sort country edate
   gen counter = _n

gen unified_countrysurveyFE =.
order unified_country, after(counter)


replace unified_countrysurveyFE = 1 if country == 63 & counter == 348 //* Australia 96									 
replace unified_countrysurveyFE = 2 if country == 63 & counter == 351 //* Australia 04							
replace unified_countrysurveyFE = 3 if country == 63 & counter == 352 //* Australia 07	(.1155743)
replace unified_countrysurveyFE = 4 if country == 63 & counter == 354 //* Australia 13
replace unified_countrysurveyFE = 5 if country == 42 & counter == 249 //* Austria 08									 
replace unified_countrysurveyFE = 6 if country == 42 & counter == 250 //* Austria 13								 
replace unified_countrysurveyFE = 10 if country == 62 & counter == 323 //* Canada 97  	 (.1977164)
replace unified_countrysurveyFE = 11 if country == 62 & counter == 325 //* Canada 04	
replace unified_countrysurveyFE = 12 if country == 62 & counter == 327 //* Canada 08
replace unified_countrysurveyFE = 13 if country == 62 & counter == 328 //* Canada 11									 
replace unified_countrysurveyFE = 14 if country == 62 & counter == 329 //* Canada 15	
replace unified_countrysurveyFE = 15 if country == 43 & counter == 264 //* Switz 99	
replace unified_countrysurveyFE = 16 if country == 43 & counter == 265 //* Switz 03
replace unified_countrysurveyFE = 17 if country == 43 & counter == 266 //* Switz 07									 
replace unified_countrysurveyFE = 18 if country == 43 & counter == 267 //* Switz 11	
replace unified_countrysurveyFE = 19 if country == 41 & counter == 227 //* Germany 02	
replace unified_countrysurveyFE = 20 if country == 41 & counter == 227 //* Germany 02b
replace unified_countrysurveyFE = 21 if country == 41 & counter == 228 //* Germany 2005									 
replace unified_countrysurveyFE = 22 if country == 41 & counter == 229 //* Germany 2009							
replace unified_countrysurveyFE = 23 if country == 41 & counter == 230 //* Germany 2013	
replace unified_countrysurveyFE = 24 if country == 13 & counter == 57 //* Denmark 1998
replace unified_countrysurveyFE = 25 if country == 13 & counter == 58 //* Denmark 2001									 
replace unified_countrysurveyFE = 26 if country == 13 & counter == 60 //* Denmark 2007					
replace unified_countrysurveyFE = 27 if country == 33 & counter == 177 //* Spain 1996 	
replace unified_countrysurveyFE = 28 if country == 33 & counter == 178 //* Spain 2000
replace unified_countrysurveyFE = 29 if country == 33 & counter == 179 //* Spain 2004									 
replace unified_countrysurveyFE = 30 if country == 33 & counter == 180 //* Spain 2008			
replace unified_countrysurveyFE = 31 if country == 14 & counter == 76 //* Finland 2003	
replace unified_countrysurveyFE = 32 if country == 14 & counter == 77 //* Finland 2007
replace unified_countrysurveyFE = 33 if country == 14 & counter == 78 //* Finland 2011									 
replace unified_countrysurveyFE = 34 if country == 14 & counter == 78 //* Finland 2015	 (.0893217) - Reused 2011
replace unified_countrysurveyFE = 35 if country == 31 & counter == 152 //* France 2007	
replace unified_countrysurveyFE = 36 if country == 51 & counter == 282 //* Britain 1997
replace unified_countrysurveyFE = 37 if country == 51 & counter == 284 //* Britain 2005									 
replace unified_countrysurveyFE = 38 if country == 51 & counter == 286 //* Britain 2015	
replace unified_countrysurveyFE = 39 if country == 34 & counter == 196 //* Greece 2009	
replace unified_countrysurveyFE = 40 if country == 34 & counter == 197 //* Greece 2012
replace unified_countrysurveyFE = 41 if country == 34 & counter == 199 //* Greece 2015							 
replace unified_countrysurveyFE = 42 if country == 53 & counter == 303 //* Ireland 2002							
replace unified_countrysurveyFE = 43 if country == 53 & counter == 304 //* Ireland 2007	
replace unified_countrysurveyFE = 44 if country == 53 & counter == 305 //* Ireland 2011
replace unified_countrysurveyFE = 45 if country == 15 & counter == 93 //* Iceland 1999									 
replace unified_countrysurveyFE = 46 if country == 15 & counter == 94 //* Iceland 2003							
replace unified_countrysurveyFE = 47 if country == 15 & counter == 95 //* Iceland 2007	
replace unified_countrysurveyFE = 48 if country == 15 & counter == 96 //* Iceland 2009
replace unified_countrysurveyFE = 49 if country == 15 & counter == 97 //* Iceland 2013									 
replace unified_countrysurveyFE = 50 if country == 32 & counter == 168 //* Italy 2006	
replace unified_countrysurveyFE = 51 if country == 22 & counter == 117 //* Netherlands 1998	
replace unified_countrysurveyFE = 52 if country == 22 & counter == 118 //* Netherlands 2002
replace unified_countrysurveyFE = 53 if country == 22 & counter == 120 //* Netherlands 2006									 
replace unified_countrysurveyFE = 54 if country == 22 & counter == 121 //* Netherlands 2010					
replace unified_countrysurveyFE = 55 if country == 12 & counter == 33 //* Norway 1997	
replace unified_countrysurveyFE = 56 if country == 12 & counter == 34 //* Norway 2001
replace unified_countrysurveyFE = 57 if country == 12 & counter == 35 //* Norway 2005									 
replace unified_countrysurveyFE = 58 if country == 12 & counter == 36 //* Norway 2009							
replace unified_countrysurveyFE = 59 if country == 12 & counter == 37 //* Norway 2013	
replace unified_countrysurveyFE = 60 if country == 64 & counter == 371 //* NZ 1996
replace unified_countrysurveyFE = 61 if country == 64 & counter == 373 //* NZ 2002									 
replace unified_countrysurveyFE = 62 if country == 64 & counter == 375 //* NZ 2008							
replace unified_countrysurveyFE = 63 if country == 64 & counter == 376 //* NZ 2011	
replace unified_countrysurveyFE = 64 if country == 64 & counter == 377 //* NZ 2014  (.0480744)
replace unified_countrysurveyFE = 65 if country == 35 & counter == 209 //* Portugal 2002									 
replace unified_countrysurveyFE = 66 if country == 35 & counter == 210 //* Portugal 2005							
replace unified_countrysurveyFE = 67 if country == 35 & counter == 211 //* Portugal 2009	
replace unified_countrysurveyFE = 68 if country == 35 & counter == 213 //* Portugal 2015
replace unified_countrysurveyFE = 69 if country == 11 & counter == 16 //* Sweden 1998									 
replace unified_countrysurveyFE = 70 if country == 11 & counter == 17 //* Sweden 2002							
replace unified_countrysurveyFE = 71 if country == 11 & counter == 18 //* Sweden 2006	
replace unified_countrysurveyFE = 72 if country == 11 & counter == 20 //* Sweden 2014 (.1794319)
replace unified_countrysurveyFE = 73 if country == 41 & counter == 226 //* Germany 1998 (.0733647)

drop if unified_ ==.

save "$data2\PolData_Mergable1.dta", replace
clear

use "$data2\CSESedit.dta"
drop _merge
merge m:1 unified_countrysurveyFE using "$data2\PolData_Mergable1.dta", force

//* Use values for countries where had to merge same data twice

replace psGEN_Polarisation_DALTON  =  .0463842 if unified_countrysurveyFE == 41 //* Greece_15
replace psECON_Polarisation_DALTON =  .0295496 if unified_countrysurveyFE == 41
replace psSOC_Polarisation_DALTON =   .1279794 if unified_countrysurveyFE == 41
replace ms_bigrange =                 .660281  if unified_countrysurveyFE == 41
replace ms_maxrange =                 .660281  if unified_countrysurveyFE == 41

replace psGEN_Polarisation_DALTON  = .0793704  if unified_countrysurveyFE == 38 //* Britain_15
replace psECON_Polarisation_DALTON = .0744825  if unified_countrysurveyFE == 38
replace psSOC_Polarisation_DALTON =  .1173575  if unified_countrysurveyFE == 38
replace ms_bigrange =                .4145874  if unified_countrysurveyFE == 38
replace ms_maxrange =               2.4098700  if unified_countrysurveyFE == 38

replace psGEN_Polarisation_DALTON  = .1794319 if unified_countrysurveyFE == 72 //* Sweden_14
replace psECON_Polarisation_DALTON = .2198088 if unified_countrysurveyFE == 72
replace psSOC_Polarisation_DALTON =  .1299008 if unified_countrysurveyFE == 72
replace ms_bigrange =                1.827026 if unified_countrysurveyFE == 72
replace ms_maxrange =                2.159445 if unified_countrysurveyFE == 72

replace psGEN_Polarisation_DALTON  = .0585269 if unified_countrysurveyFE == 68 //* Portugal_15
replace psECON_Polarisation_DALTON = .1637054 if unified_countrysurveyFE == 68
replace psSOC_Polarisation_DALTON =  .0694993 if unified_countrysurveyFE == 68
replace ms_bigrange =                .58754   if unified_countrysurveyFE == 68
replace ms_maxrange =                .58754   if unified_countrysurveyFE == 68

replace psGEN_Polarisation_DALTON  = .0893217  if unified_countrysurveyFE == 33 //* Finland_11
replace psECON_Polarisation_DALTON = .1072579  if unified_countrysurveyFE == 33
replace psSOC_Polarisation_DALTON =  .1402372  if unified_countrysurveyFE == 33
replace ms_bigrange =                .3589249  if unified_countrysurveyFE == 33
replace ms_maxrange =                1.566331  if unified_countrysurveyFE == 33

replace psGEN_Polarisation_DALTON  = .0893217  if unified_countrysurveyFE == 34 //* Finland_15
replace psECON_Polarisation_DALTON = .1072579  if unified_countrysurveyFE == 34
replace psSOC_Polarisation_DALTON =  .1402372  if unified_countrysurveyFE == 34
replace ms_bigrange =                .3589249  if unified_countrysurveyFE == 34
replace ms_maxrange =               1.566331   if unified_countrysurveyFE == 34

replace psGEN_Polarisation_DALTON  = .1052716 if unified_countrysurveyFE == 23 //* Germany_13
replace psECON_Polarisation_DALTON = .1053578 if unified_countrysurveyFE == 23
replace psSOC_Polarisation_DALTON =  .0411412 if unified_countrysurveyFE == 23
replace ms_bigrange =                .9658005 if unified_countrysurveyFE == 23
replace ms_maxrange =               1.4568050 if unified_countrysurveyFE == 23

replace psGEN_Polarisation_DALTON  = .0996020  if unified_countrysurveyFE == 19 //* Germany 2002
replace psECON_Polarisation_DALTON = .0860636  if unified_countrysurveyFE == 19
replace psSOC_Polarisation_DALTON =  .0866665  if unified_countrysurveyFE == 19
replace ms_bigrange =                .7187306  if unified_countrysurveyFE == 19
replace ms_maxrange =               1.6391590  if unified_countrysurveyFE == 19

replace psGEN_Polarisation_DALTON  = .1240309 if unified_countrysurveyFE == 6 //* Austria 2013
replace psECON_Polarisation_DALTON = .1919135 if unified_countrysurveyFE == 6
replace psSOC_Polarisation_DALTON =  .0215927 if unified_countrysurveyFE == 6
replace ms_bigrange =               1.242234  if unified_countrysurveyFE == 6
replace ms_maxrange =               1.242234  if unified_countrysurveyFE == 6


* Note: Treating Belgium separately to split Wallonia and Flanders into two separate party systems. Recoded vote share as a proportion of each respective region.
 
 
** Wallonia and Flanders copied and pasted from aggregate section (some problem with merging here) **
 
replace psGEN_Polarisation_DALTON  = .03264482 if unified_countrysurveyFE == 7 //* Flanders 1999
replace psECON_Polarisation_DALTON = .09137394 if unified_countrysurveyFE == 7
replace psSOC_Polarisation_DALTON =  .07383612 if unified_countrysurveyFE == 7
replace ms_bigrange =                .3683518  if unified_countrysurveyFE == 7
replace ms_maxrange =                .3683518  if unified_countrysurveyFE == 7
 
replace psGEN_Polarisation_DALTON  = .141782  if unified_countrysurveyFE == 9 //*Flanders 2003
replace psECON_Polarisation_DALTON = .0753395 if unified_countrysurveyFE == 9
replace psSOC_Polarisation_DALTON =  .6897663 if unified_countrysurveyFE == 9
replace ms_bigrange =                1.493877  if unified_countrysurveyFE == 9
replace ms_maxrange =                1.493877  if unified_countrysurveyFE == 9
 
replace psGEN_Polarisation_DALTON  = .1160871 if unified_countrysurveyFE == 74 //*Flanders 2014
replace psECON_Polarisation_DALTON = .1108005 if unified_countrysurveyFE == 74
replace psSOC_Polarisation_DALTON =  .1158062 if unified_countrysurveyFE == 74
replace ms_bigrange =                .0368664 if unified_countrysurveyFE == 74
replace ms_maxrange =                1.478137  if unified_countrysurveyFE == 74
 
replace psGEN_Polarisation_DALTON  = .04164276 if unified_countrysurveyFE == 8 //*Wallonia 1999
replace psECON_Polarisation_DALTON = .09091306 if unified_countrysurveyFE == 8
replace psSOC_Polarisation_DALTON =  .0733096  if unified_countrysurveyFE == 8
replace ms_bigrange =                .2958122  if unified_countrysurveyFE == 8
replace ms_maxrange =                .53703    if unified_countrysurveyFE == 8
 
replace psGEN_Polarisation_DALTON  = .1676886 if unified_countrysurveyFE == 75 //*Wallonia 2014
replace psECON_Polarisation_DALTON = .2262133 if unified_countrysurveyFE == 75
replace psSOC_Polarisation_DALTON =  .1194411 if unified_countrysurveyFE == 75
replace ms_bigrange =                1.801075  if unified_countrysurveyFE == 75
replace ms_maxrange =                1.982936  if unified_countrysurveyFE == 75
 

save "$data2\CSESedit.dta", replace
clear


 ********************************************************************* Electoral Systems ************************************************************************

import delimited "$data2\es_data-v3.csv"

replace country = "Germany" if ccode == 260 
replace country = "Sweden" if ccode == 380

encode country, gen(country_n)

order country_n year, after(country)

keep if country_n == 7 | country_n == 8 | country_n == 12 | country_n == 20 | country_n == 32 | country_n == 40 | country_n == 41 | country_n == 43 ///
                       | country_n == 45 | country_n == 52 | country_n == 55 | country_n == 57 | country_n == 69 | country_n == 75 | country_n == 87 ///
					   | country_n == 88 | country_n == 92 | country_n == 101 | country_n == 115 | country_n == 122 | country_n == 123 | country_n == 131

sort country year

destring legislative_type elecrule tier1_formula tier2_formula tier3_formula tier4_formula mixed_type ///
multi multi_linked seats tier1_avemag tier1_districts upperseats uppertier tier2_districts tier3_districts ///
tier4_districts enep enep_others enep1 enpp enpp_others enpp1 enpres preselecrule month day secondround thirdround, replace force

replace uppertier =. if uppertier == -99
replace upperseat =. if upperseat == -99

gen elec_n =.               //* Dummy for years where 2+ elections
replace elec_n = 1 if country_n == 32 & year == 1953 & month == 4 | country_n == 45 & year == 1989 & month == 6  | country_n == 45 & year == 2012 & month == 5  | country_n == 45 & year == 2015 & month == 1  |  country_n == 52 & year == 1959 & month == 6  | country_n == 55 & year == 1982 & month == 2  | country_n == 132 & year == 1974 & month == 2
replace elec_n = 2 if country_n == 32 & year == 1953 & month == 9 | country_n == 45 & year == 1989 & month == 11 | country_n == 45 & year == 2012 & month == 6  | country_n == 45 & year == 2015 & month == 9  |  country_n == 52 & year == 1959 & month == 10 | country_n == 55 & year == 1982 & month == 11 | country_n == 132 & year == 1974 & month == 10

gen master_id =.
order master_id, after(country_n)

drop if presidential == 1 //* Drop presidential elections

replace master_id = -1   if country_n  == 7 & year == 1949 //* AUSTRALIA
replace master_id = 1   if country_n  == 7 & year == 1951
replace master_id = 2   if country_n  == 7 & year == 1954
replace master_id = 3   if country_n  == 7 & year == 1955
replace master_id = 4   if country_n  == 7 & year == 1958
replace master_id = 5   if country_n  == 7 & year == 1961
replace master_id = 6   if country_n  == 7 & year == 1963
replace master_id = 7   if country_n  == 7 & year == 1966
replace master_id = 8  if country_n  == 7 & year == 1969
replace master_id = 9  if country_n  == 7 & year == 1972
replace master_id = 10  if country_n  == 7 & year == 1974
replace master_id = 11  if country_n  == 7 & year == 1975
replace master_id = 12  if country_n  == 7 & year == 1977
replace master_id = 13  if country_n  == 7 & year == 1980
replace master_id = 14  if country_n  == 7 & year == 1983
replace master_id = 15  if country_n  == 7 & year == 1984
replace master_id = 16  if country_n  == 7 & year == 1987
replace master_id = 17  if country_n  == 7 & year == 1990
replace master_id = 18  if country_n  == 7 & year == 1993
replace master_id = 19  if country_n  == 7 & year == 1996
replace master_id = 20  if country_n  == 7 & year == 1998
replace master_id = 21  if country_n  == 7 & year == 2001
replace master_id = 22  if country_n  == 7 & year == 2004
replace master_id = 23  if country_n  == 7 & year == 2007
replace master_id = 24  if country_n  == 7 & year == 2010
replace master_id = 25  if country_n  == 7 & year == 2013
replace master_id = 26  if country_n  == 7 & year == 2016

replace master_id = -2  if country_n  == 8 & year == 1949 //* AUSTRIA
replace master_id = 27  if country_n  == 8 & year == 1953
replace master_id = 28  if country_n  == 8 & year == 1956
replace master_id = 29  if country_n  == 8 & year == 1959
replace master_id = 30  if country_n  == 8 & year == 1962
replace master_id = 31  if country_n  == 8 & year == 1966
replace master_id = 32  if country_n  == 8 & year == 1970
replace master_id = 33  if country_n  == 8 & year == 1971
replace master_id = 34  if country_n  == 8 & year == 1975
replace master_id = 35  if country_n  == 8 & year == 1979
replace master_id = 36  if country_n  == 8 & year == 1983
replace master_id = 37  if country_n  == 8 & year == 1986
replace master_id = 38  if country_n  == 8 & year == 1990
replace master_id = 39  if country_n  == 8 & year == 1994
replace master_id = 40  if country_n  == 8 & year == 1995
replace master_id = 41  if country_n  == 8 & year == 1999
replace master_id = 42  if country_n  == 8 & year == 2002
replace master_id = 43  if country_n  == 8 & year == 2006
replace master_id = 44  if country_n  == 8 & year == 2008
replace master_id = 45  if country_n  == 8 & year == 2013

replace master_id = -3  if country_n  == 20 & year == 1949 //* CANADA
replace master_id = 46  if country_n  == 20 & year == 1953
replace master_id = 47  if country_n  == 20 & year == 1957
replace master_id = 48  if country_n  == 20 & year == 1958
replace master_id = 49  if country_n  == 20 & year == 1962
replace master_id = 50  if country_n  == 20 & year == 1963
replace master_id = 51  if country_n  == 20 & year == 1965
replace master_id = 52  if country_n  == 20 & year == 1968
replace master_id = 53  if country_n  == 20 & year == 1972
replace master_id = 54  if country_n  == 20 & year == 1974
replace master_id = 55  if country_n  == 20 & year == 1979 
replace master_id = 56  if country_n  == 20 & year == 1980 
replace master_id = 57  if country_n  == 20 & year == 1984
replace master_id = 58  if country_n  == 20 & year == 1988
replace master_id = 59  if country_n  == 20 & year == 1993
replace master_id = 60  if country_n  == 20 & year == 1997
replace master_id = 61  if country_n  == 20 & year == 2000
replace master_id = 62  if country_n  == 20 & year == 2004
replace master_id = 63  if country_n  == 20 & year == 2006
replace master_id = 64  if country_n  == 20 & year == 2008
replace master_id = 65  if country_n  == 20 & year == 2011
replace master_id = 66  if country_n  == 20 & year == 2015
														
replace master_id = -4  if country_n  == 32 & year == 1947 //* DENMARK
replace master_id = 67  if country_n  == 32 & year == 1950
replace master_id = 68  if country_n  == 32 & year == 1953 & elec_n == 1
replace master_id = 69  if country_n  == 32 & year == 1953 & elec_n == 2
replace master_id = 70 if country_n  == 32 & year == 1957
replace master_id = 71 if country_n  == 32 & year == 1960
replace master_id = 72 if country_n  == 32 & year == 1964
replace master_id = 73 if country_n  == 32 & year == 1966
replace master_id = 74 if country_n  == 32 & year == 1968
replace master_id = 75 if country_n  == 32 & year == 1971
replace master_id = 76 if country_n  == 32 & year == 1973 
replace master_id = 77 if country_n  == 32 & year == 1975 
replace master_id = 78 if country_n  == 32 & year == 1977
replace master_id = 79 if country_n  == 32 & year == 1979
replace master_id = 80 if country_n  == 32 & year == 1981
replace master_id = 81 if country_n  == 32 & year == 1984
replace master_id = 82 if country_n  == 32 & year == 1987
replace master_id = 83 if country_n  == 32 & year == 1988
replace master_id = 84 if country_n  == 32 & year == 1990
replace master_id = 85 if country_n  == 32 & year == 1994
replace master_id = 86 if country_n  == 32 & year == 1998
replace master_id = 87 if country_n  == 32 & year == 2001						
replace master_id = 88 if country_n  == 32 & year == 2005
replace master_id = 89 if country_n  == 32 & year == 2007
replace master_id = 90 if country_n  == 32 & year == 2011
replace master_id = 91 if country_n  == 32 & year == 2015									
								
replace master_id = -5 if country_n  == 40 & year == 1948 //* FINLAND
replace master_id = 92 if country_n  == 40 & year == 1951
replace master_id = 93 if country_n  == 40 & year == 1954
replace master_id = 94 if country_n  == 40 & year == 1958
replace master_id = 95 if country_n  == 40 & year == 1962
replace master_id = 96 if country_n  == 40 & year == 1966
replace master_id = 97 if country_n  == 40 & year == 1970
replace master_id = 98 if country_n  == 40 & year == 1972
replace master_id = 99 if country_n  == 40 & year == 1975
replace master_id = 100 if country_n  == 40 & year == 1979
replace master_id = 101 if country_n  == 40 & year == 1983 
replace master_id = 102 if country_n  == 40 & year == 1987 
replace master_id = 103 if country_n  == 40 & year == 1991
replace master_id = 104 if country_n  == 40 & year == 1995
replace master_id = 105 if country_n  == 40 & year == 1999
replace master_id = 106 if country_n  == 40 & year == 2003
replace master_id = 107 if country_n  == 40 & year == 2007
replace master_id = 108 if country_n  == 40 & year == 2011
replace master_id = 109 if country_n  == 40 & year == 2015

replace master_id = -6 if country_n  == 41 & year == 1946 //* FRANCE
replace master_id = 110 if country_n  == 41 & year == 1951
replace master_id = 111 if country_n  == 41 & year == 1956
replace master_id = 112 if country_n  == 41 & year == 1958
replace master_id = 113 if country_n  == 41 & year == 1962
replace master_id = 114 if country_n  == 41 & year == 1967
replace master_id = 115 if country_n  == 41 & year == 1968
replace master_id = 116 if country_n  == 41 & year == 1973
replace master_id = 117 if country_n  == 41 & year == 1978
replace master_id = 118 if country_n  == 41 & year == 1981
replace master_id = 119 if country_n  == 41 & year == 1986
replace master_id = 120 if country_n  == 41 & year == 1988 
replace master_id = 121 if country_n  == 41 & year == 1993 
replace master_id = 122 if country_n  == 41 & year == 1997
replace master_id = 123 if country_n  == 41 & year == 2002
replace master_id = 124 if country_n  == 41 & year == 2007
replace master_id = 125 if country_n  == 41 & year == 2012

replace master_id = -7  if country_n  == 43 & year == 1949 //* GERMANY
replace master_id = 126 if country_n  == 43 & year == 1953
replace master_id = 127 if country_n  == 43 & year == 1957
replace master_id = 128 if country_n  == 43 & year == 1961
replace master_id = 129 if country_n  == 43 & year == 1965
replace master_id = 130 if country_n  == 43 & year == 1969
replace master_id = 131 if country_n  == 43 & year == 1972
replace master_id = 132 if country_n  == 43 & year == 1976
replace master_id = 133 if country_n  == 43 & year == 1980
replace master_id = 134 if country_n  == 43 & year == 1983
replace master_id = 135 if country_n  == 43 & year == 1987
replace master_id = 136 if country_n  == 43 & year == 1990 
replace master_id = 137 if country_n  == 43 & year == 1994 
replace master_id = 138 if country_n  == 43 & year == 1998
replace master_id = 139 if country_n  == 43 & year == 2002
replace master_id = 140 if country_n  == 43 & year == 2005
replace master_id = 141 if country_n  == 43 & year == 2009
replace master_id = 142 if country_n  == 43 & year == 2013

replace master_id = -8  if country_n  == 45 & year == 1964 //* GREECE
replace master_id = 143 if country_n  == 45 & year == 1974
replace master_id = 144 if country_n  == 45 & year == 1977
replace master_id = 145 if country_n  == 45 & year == 1981
replace master_id = 146 if country_n  == 45 & year == 1985 
replace master_id = 147 if country_n  == 45 & year == 1989 & elec_n == 1
replace master_id = 148 if country_n  == 45 & year == 1989 & elec_n == 2
replace master_id = 149 if country_n  == 45 & year == 1990
replace master_id = 150 if country_n  == 45 & year == 1993
replace master_id = 151 if country_n  == 45 & year == 1996
replace master_id = 152 if country_n  == 45 & year == 2000
replace master_id = 153 if country_n  == 45 & year == 2004
replace master_id = 154 if country_n  == 45 & year == 2007
replace master_id = 155 if country_n  == 45 & year == 2009
replace master_id = 156 if country_n  == 45 & year == 2012 & elec_n == 1
replace master_id = 157 if country_n  == 45 & year == 2012 & elec_n == 2
replace master_id = 158 if country_n  == 45 & year == 2015 & elec_n == 1
replace master_id = 159 if country_n  == 45 & year == 2015 & elec_n == 2

replace master_id = -9  if country_n  == 52 & year == 1949 //* ICELAND
replace master_id = 160 if country_n  == 52 & year == 1953
replace master_id = 161 if country_n  == 52 & year == 1956
replace master_id = 162 if country_n  == 52 & year == 1959 & elec_n == 1
replace master_id = 163 if country_n  == 52 & year == 1959 & elec_n == 2
replace master_id = 164 if country_n  == 52 & year == 1963
replace master_id = 165 if country_n  == 52 & year == 1967
replace master_id = 166 if country_n  == 52 & year == 1971
replace master_id = 167 if country_n  == 52 & year == 1974
replace master_id = 168 if country_n  == 52 & year == 1978
replace master_id = 169 if country_n  == 52 & year == 1979 
replace master_id = 170 if country_n  == 52 & year == 1983 
replace master_id = 171 if country_n  == 52 & year == 1987
replace master_id = 172 if country_n  == 52 & year == 1991
replace master_id = 173 if country_n  == 52 & year == 1995
replace master_id = 174 if country_n  == 52 & year == 1999
replace master_id = 175 if country_n  == 52 & year == 2003
replace master_id = 176 if country_n  == 52 & year == 2007
replace master_id = 177 if country_n  == 52 & year == 2009
replace master_id = 178 if country_n  == 52 & year == 2013
replace master_id = 179 if country_n  == 52 & year == 2016

replace master_id = -10 if country_n  == 55 & year == 1948  //* IRELAND 
replace master_id = 180 if country_n  == 55 & year == 1951
replace master_id = 181 if country_n  == 55 & year == 1954
replace master_id = 182 if country_n  == 55 & year == 1957
replace master_id = 183 if country_n  == 55 & year == 1961
replace master_id = 184 if country_n  == 55 & year == 1965
replace master_id = 185 if country_n  == 55 & year == 1969
replace master_id = 186 if country_n  == 55 & year == 1973
replace master_id = 187 if country_n  == 55 & year == 1977
replace master_id = 188 if country_n  == 55 & year == 1981
replace master_id = 189 if country_n  == 55 & year == 1982 & elec_n == 1
replace master_id = 190 if country_n  == 55 & year == 1982 & elec_n == 2
replace master_id = 191 if country_n  == 55 & year == 1987 
replace master_id = 192 if country_n  == 55 & year == 1989
replace master_id = 193 if country_n  == 55 & year == 1992
replace master_id = 194 if country_n  == 55 & year == 1997
replace master_id = 195 if country_n  == 55 & year == 2002
replace master_id = 196 if country_n  == 55 & year == 2007
replace master_id = 197 if country_n  == 55 & year == 2011
replace master_id = 198 if country_n  == 55 & year == 2016

replace master_id = -11 if country_n  == 57 & year == 1948 //* Italy
replace master_id = 199 if country_n  == 57 & year == 1953
replace master_id = 200 if country_n  == 57 & year == 1958
replace master_id = 201 if country_n  == 57 & year == 1963
replace master_id = 202 if country_n  == 57 & year == 1968
replace master_id = 203 if country_n  == 57 & year == 1972
replace master_id = 204 if country_n  == 57 & year == 1976
replace master_id = 205 if country_n  == 57 & year == 1979
replace master_id = 206 if country_n  == 57 & year == 1983
replace master_id = 207 if country_n  == 57 & year == 1987
replace master_id = 208 if country_n  == 57 & year == 1992
replace master_id = 209 if country_n  == 57 & year == 1994 
replace master_id = 210 if country_n  == 57 & year == 1996 
replace master_id = 211 if country_n  == 57 & year == 2001
replace master_id = 212 if country_n  == 57 & year == 2006
replace master_id = 213 if country_n  == 57 & year == 2008
replace master_id = 214 if country_n  == 57 & year == 2013

replace master_id = 216 if country_n  == 69 & year == 1954 //* luxembourg
replace master_id = 217 if country_n  == 69 & year == 1959
replace master_id = 218 if country_n  == 69 & year == 1964
replace master_id = 219 if country_n  == 69 & year == 1968
replace master_id = 220 if country_n  == 69 & year == 1974
replace master_id = 221 if country_n  == 69 & year == 1979
replace master_id = 222 if country_n  == 69 & year == 1984
replace master_id = 223 if country_n  == 69 & year == 1989
replace master_id = 224 if country_n  == 69 & year == 1994 
replace master_id = 225 if country_n  == 69 & year == 1999 
replace master_id = 226 if country_n  == 69 & year == 2004
replace master_id = 227 if country_n  == 69 & year == 2009
replace master_id = 228 if country_n  == 69 & year == 2013

replace master_id = 229 if country_n  == 75 & year == 1966 //* Malta
replace master_id = 230 if country_n  == 75 & year == 1971
replace master_id = 231 if country_n  == 75 & year == 1976
replace master_id = 232 if country_n  == 75 & year == 1981
replace master_id = 233 if country_n  == 75 & year == 1987
replace master_id = 234 if country_n  == 75 & year == 1992
replace master_id = 235 if country_n  == 75 & year == 1996
replace master_id = 236 if country_n  == 75 & year == 1998
replace master_id = 237 if country_n  == 75 & year == 2003
replace master_id = 238 if country_n  == 75 & year == 2008

replace master_id = -12 if country_n  == 87 & year == 1948 //* Netherlands
replace master_id = 240 if country_n  == 87 & year == 1952
replace master_id = 241 if country_n  == 87 & year == 1956
replace master_id = 242 if country_n  == 87 & year == 1959
replace master_id = 243 if country_n  == 87 & year == 1963
replace master_id = 244 if country_n  == 87 & year == 1967
replace master_id = 245 if country_n  == 87 & year == 1971
replace master_id = 246 if country_n  == 87 & year == 1972
replace master_id = 247 if country_n  == 87 & year == 1977
replace master_id = 248 if country_n  == 87 & year == 1981
replace master_id = 249 if country_n  == 87 & year == 1982 
replace master_id = 250 if country_n  == 87 & year == 1986 
replace master_id = 251 if country_n  == 87 & year == 1989
replace master_id = 252 if country_n  == 87 & year == 1994
replace master_id = 253 if country_n  == 87 & year == 1998
replace master_id = 254 if country_n  == 87 & year == 2002
replace master_id = 255 if country_n  == 87 & year == 2003
replace master_id = 256 if country_n  == 87 & year == 2006
replace master_id = 257 if country_n  == 87 & year == 2010
replace master_id = 258 if country_n  == 87 & year == 2012

replace master_id = -13 if country_n  == 88 & year == 1949 //* New Zealand
replace master_id = 259 if country_n  == 88 & year == 1951
replace master_id = 260 if country_n  == 88 & year == 1954
replace master_id = 261 if country_n  == 88 & year == 1957
replace master_id = 262 if country_n  == 88 & year == 1960
replace master_id = 263 if country_n  == 88 & year == 1963
replace master_id = 264 if country_n  == 88 & year == 1966
replace master_id = 265 if country_n  == 88 & year == 1969
replace master_id = 266 if country_n  == 88 & year == 1972
replace master_id = 267 if country_n  == 88 & year == 1975
replace master_id = 268 if country_n  == 88 & year == 1978 
replace master_id = 269 if country_n  == 88 & year == 1981 
replace master_id = 270 if country_n  == 88 & year == 1984
replace master_id = 271 if country_n  == 88 & year == 1987
replace master_id = 272 if country_n  == 88 & year == 1990
replace master_id = 273 if country_n  == 88 & year == 1993
replace master_id = 274 if country_n  == 88 & year == 1996
replace master_id = 275 if country_n  == 88 & year == 1999
replace master_id = 276 if country_n  == 88 & year == 2002
replace master_id = 277 if country_n  == 88 & year == 2005
replace master_id = 278 if country_n  == 88 & year == 2008
replace master_id = 279 if country_n  == 88 & year == 2011						
replace master_id = 280 if country_n  == 88 & year == 2014

replace master_id = -14 if country_n  == 92 & year == 1949 //* Norway
replace master_id = 281 if country_n  == 92 & year == 1953
replace master_id = 282 if country_n  == 92 & year == 1957
replace master_id = 283 if country_n  == 92 & year == 1961
replace master_id = 284 if country_n  == 92 & year == 1965
replace master_id = 285 if country_n  == 92 & year == 1969
replace master_id = 286 if country_n  == 92 & year == 1973
replace master_id = 287 if country_n  == 92 & year == 1977
replace master_id = 288 if country_n  == 92 & year == 1981
replace master_id = 289 if country_n  == 92 & year == 1985
replace master_id = 290 if country_n  == 92 & year == 1989 
replace master_id = 291 if country_n  == 92 & year == 1993 
replace master_id = 292 if country_n  == 92 & year == 1997
replace master_id = 293 if country_n  == 92 & year == 2001
replace master_id = 294 if country_n  == 92 & year == 2005
replace master_id = 295 if country_n  == 92 & year == 2009
replace master_id = 296 if country_n  == 92 & year == 2013

replace master_id = 297 if country_n  == 101 & year == 1976 //* Portugal
replace master_id = 298 if country_n  == 101 & year == 1979
replace master_id = 299 if country_n  == 101 & year == 1980
replace master_id = 300 if country_n  == 101 & year == 1983
replace master_id = 301 if country_n  == 101 & year == 1985
replace master_id = 302 if country_n  == 101 & year == 1987
replace master_id = 303 if country_n  == 101 & year == 1991
replace master_id = 304 if country_n  == 101 & year == 1995
replace master_id = 305 if country_n  == 101 & year == 1999
replace master_id = 306 if country_n  == 101 & year == 2002
replace master_id = 307 if country_n  == 101 & year == 2005
replace master_id = 308 if country_n  == 101 & year == 2009 
replace master_id = 309 if country_n  == 101 & year == 2011 
replace master_id = 310 if country_n  == 101 & year == 2015

replace master_id = 311 if country_n  == 115 & year == 1977 //* Spain
replace master_id = 312 if country_n  == 115 & year == 1979
replace master_id = 313 if country_n  == 115 & year == 1982
replace master_id = 314 if country_n  == 115 & year == 1986
replace master_id = 315 if country_n  == 115 & year == 1989
replace master_id = 316 if country_n  == 115 & year == 1993
replace master_id = 317 if country_n  == 115 & year == 1996
replace master_id = 318 if country_n  == 115 & year == 2000
replace master_id = 319 if country_n  == 115 & year == 2004
replace master_id = 320 if country_n  == 115 & year == 2008
replace master_id = 321 if country_n  == 115 & year == 2011
replace master_id = 322 if country_n  == 115 & year == 2015
replace master_id = 323 if country_n  == 115 & year == 2016 

replace master_id = -15 if country_n  == 122 & year == 1948 //* Sweden
replace master_id = 324 if country_n  == 122 & year == 1952
replace master_id = 325 if country_n  == 122 & year == 1956
replace master_id = 326 if country_n  == 122 & year == 1958
replace master_id = 327 if country_n  == 122 & year == 1960
replace master_id = 328 if country_n  == 122 & year == 1964
replace master_id = 329 if country_n  == 122 & year == 1968
replace master_id = 330 if country_n  == 122 & year == 1970
replace master_id = 331 if country_n  == 122 & year == 1973
replace master_id = 332 if country_n  == 122 & year == 1976
replace master_id = 333 if country_n  == 122 & year == 1979
replace master_id = 334 if country_n  == 122 & year == 1982 
replace master_id = 335 if country_n  == 122 & year == 1985 
replace master_id = 336 if country_n  == 122 & year == 1988
replace master_id = 337 if country_n  == 122 & year == 1991
replace master_id = 338 if country_n  == 122 & year == 1994
replace master_id = 339 if country_n  == 122 & year == 1998
replace master_id = 340 if country_n  == 122 & year == 2002
replace master_id = 341 if country_n  == 122 & year == 2006
replace master_id = 342 if country_n  == 122 & year == 2010
replace master_id = 343 if country_n  == 122 & year == 2014

replace master_id = -16 if country_n  == 123 & year == 1947 //* Switzerland
replace master_id = 344 if country_n  == 123 & year == 1951
replace master_id = 345 if country_n  == 123 & year == 1955
replace master_id = 346 if country_n  == 123 & year == 1959
replace master_id = 347 if country_n  == 123 & year == 1963
replace master_id = 348 if country_n  == 123 & year == 1967
replace master_id = 349 if country_n  == 123 & year == 1971
replace master_id = 350 if country_n  == 123 & year == 1975
replace master_id = 351 if country_n  == 123 & year == 1979
replace master_id = 352 if country_n  == 123 & year == 1983
replace master_id = 353 if country_n  == 123 & year == 1987
replace master_id = 354 if country_n  == 123 & year == 1991 
replace master_id = 355 if country_n  == 123 & year == 1995 
replace master_id = 356 if country_n  == 123 & year == 1999
replace master_id = 357 if country_n  == 123 & year == 2003
replace master_id = 358 if country_n  == 123 & year == 2007
replace master_id = 359 if country_n  == 123 & year == 2011
replace master_id = 360 if country_n  == 123 & year == 2015

replace master_id = -17 if country_n  == 131 & year == 1945 //* United Kingdom
replace master_id = 361 if country_n  == 131 & year == 1950
replace master_id = 362 if country_n  == 131 & year == 1951
replace master_id = 363 if country_n  == 131 & year == 1955
replace master_id = 364 if country_n  == 131 & year == 1959
replace master_id = 365 if country_n  == 131 & year == 1964
replace master_id = 366 if country_n  == 131 & year == 1966
replace master_id = 367 if country_n  == 131 & year == 1970
replace master_id = 368 if country_n  == 131 & year == 1974 & elec_n == 1
replace master_id = 369 if country_n  == 131 & year == 1974 & elec_n == 2
replace master_id = 370 if country_n  == 131 & year == 1979 
replace master_id = 371 if country_n  == 131 & year == 1983 
replace master_id = 372 if country_n  == 131 & year == 1987 
replace master_id = 373 if country_n  == 131 & year == 1992
replace master_id = 374 if country_n  == 131 & year == 1997
replace master_id = 375 if country_n  == 131 & year == 2001
replace master_id = 376 if country_n  == 131 & year == 2005
replace master_id = 377 if country_n  == 131 & year == 2010
replace master_id = 378 if country_n  == 131 & year == 2015

replace master_id = -18 if country_n  == 12 & year == 1949 //* Belgium
replace master_id = 379 if country_n  == 12 & year == 1950
replace master_id = 380 if country_n  == 12 & year == 1954
replace master_id = 381 if country_n  == 12 & year == 1958
replace master_id = 382 if country_n  == 12 & year == 1961
replace master_id = 383 if country_n  == 12 & year == 1965
replace master_id = 384 if country_n  == 12 & year == 1968
replace master_id = 385 if country_n  == 12 & year == 1971
replace master_id = 386 if country_n  == 12 & year == 1974
replace master_id = 387 if country_n  == 12 & year == 1977
replace master_id = 388 if country_n  == 12 & year == 1978
replace master_id = 389 if country_n  == 12 & year == 1981 
replace master_id = 390 if country_n  == 12 & year == 1985 
replace master_id = 391 if country_n  == 12 & year == 1987
replace master_id = 392 if country_n  == 12 & year == 1991
replace master_id = 393 if country_n  == 12 & year == 1995
replace master_id = 394 if country_n  == 12 & year == 1999
replace master_id = 395 if country_n  == 12 & year == 2003
replace master_id = 396 if country_n  == 12 & year == 2007
replace master_id = 397 if country_n  == 12 & year == 2010
replace master_id = 398 if country_n  == 12 & year == 2014

drop if master_id ==.

* Identify 'Decisive Electoral Tiers' (Carter 2002: 129 - 131; Lijphart 1994: 30 -39)

generate uptier_decisive = .

replace uptier_decisive = 1 if country_n == 43 | country_n == 57 & year > 1993 & year < 2002 | country_n == 92 & year > 1988 | country_n == 32 | country_n == 122 & year > 1969 | country_n == 88 & year > 1995

* Replace Tier Info nearest available if missing *

sort country_n master_id
bysort country_n (master_id): replace tier2_districts = (tier2_districts[_n-1] + tier2_districts[_n+1])/2 if tier2_districts ==.
bysort country_n (master_id): replace tier2_districts = (tier2_districts[_n-2] + tier2_districts[_n+1])/2 if tier2_districts ==.
bysort country_n (master_id): replace tier2_districts = (tier2_districts[_n-1] + tier2_districts[_n+2])/2 if tier2_districts ==.
bysort country_n (master_id): replace tier2_districts = (tier2_districts[_n-2] + tier2_districts[_n+2])/2 if tier2_districts ==.
bysort country_n (master_id): replace tier2_districts = (tier2_districts[_n-3] + tier2_districts[_n+2])/2 if tier2_districts ==.
bysort country_n (master_id): replace tier2_districts = (tier2_districts[_n-2] + tier2_districts[_n+3])/2 if tier2_districts ==.
bysort country_n (master_id): replace tier2_districts = (tier2_districts[_n-3] + tier2_districts[_n+3])/2 if tier2_districts ==.
bysort country_n (master_id): replace tier2_districts = tier2_districts[_n+1] if tier2_districts ==.
bysort country_n (master_id): replace tier2_districts = tier2_districts[_n-1] if tier2_districts ==.
bysort country_n (master_id): replace tier2_districts = (tier2_districts[_n-1] + tier2_districts[_n+1])/2 if tier2_districts <0

bysort country_n (master_id): replace upperseats = (upperseats[_n-1] + upperseats[_n+1])/2 if upperseats ==.
bysort country_n (master_id): replace upperseats = (upperseats[_n-2] + upperseats[_n+1])/2 if upperseats ==.
bysort country_n (master_id): replace upperseats = (upperseats[_n-1] + upperseats[_n+2])/2 if upperseats ==.
bysort country_n (master_id): replace upperseats = (upperseats[_n-2] + upperseats[_n+2])/2 if upperseats ==.
bysort country_n (master_id): replace upperseats = (upperseats[_n-3] + upperseats[_n+2])/2 if upperseats ==.
bysort country_n (master_id): replace upperseats = (upperseats[_n-2] + upperseats[_n+3])/2 if upperseats ==.
bysort country_n (master_id): replace upperseats = (upperseats[_n-3] + upperseats[_n+3])/2 if upperseats ==.
bysort country_n (master_id): replace upperseats = upperseats[_n+1] if upperseats ==.
bysort country_n (master_id): replace upperseats = upperseats[_n-1] if upperseats ==.
bysort country_n (master_id): replace upperseats = (upperseats[_n-1] + upperseats[_n+1])/2 if upperseats <0

bysort country_n (master_id): replace tier1_avemag = (tier1_avemag[_n-1] + tier1_avemag[_n+1])/2 if tier1_avemag ==.
bysort country_n (master_id): replace tier1_avemag = (tier1_avemag[_n-2] + tier1_avemag[_n+1])/2 if tier1_avemag ==.
bysort country_n (master_id): replace tier1_avemag = (tier1_avemag[_n-1] + tier1_avemag[_n+2])/2 if tier1_avemag ==.
bysort country_n (master_id): replace tier1_avemag = (tier1_avemag[_n-2] + tier1_avemag[_n+2])/2 if tier1_avemag ==.
bysort country_n (master_id): replace tier1_avemag = (tier1_avemag[_n-3] + tier1_avemag[_n+2])/2 if tier1_avemag ==.
bysort country_n (master_id): replace tier1_avemag = (tier1_avemag[_n-2] + tier1_avemag[_n+3])/2 if tier1_avemag ==.
bysort country_n (master_id): replace tier1_avemag = (tier1_avemag[_n-3] + tier1_avemag[_n+3])/2 if tier1_avemag ==.
bysort country_n (master_id): replace tier1_avemag = tier1_avemag[_n+1] if tier1_avemag ==.
bysort country_n (master_id): replace tier1_avemag = tier1_avemag[_n-1] if tier1_avemag ==.
bysort country_n (master_id): replace tier1_avemag = (tier1_avemag[_n-1] + tier1_avemag[_n+1])/2 if tier1_avemag <0

generate tier2_avemag = upperseats / tier2_districts


generate decisive = .
replace decisive = tier1_avemag if uptier_d ==. 
replace decisive = tier2_avemag if uptier_d == 1

order country_n year decisive tier1_avemag uptier_d upperseats tier2_dis tier2_avemag, after(country)

generate effective_thresh = 75/(decisive+1)

order effective_thr, after(decisive)

generate legal_thresh = .   //* Data taken from Reading University's Electoral Change in Europe since 1945 reports.
order legal_thresh, after (effective)
replace legal_thresh = 4 if country_n == 8 & year >= 1992
replace legal_thresh = 5 if country_n == 12 & year >= 2003
replace legal_thresh = 2.5 if country_n == 32 & year >= 1953
replace legal_thresh = 2 if country_n == 32 & year >= 1961
replace legal_thresh = 5 if country_n == 41 & year == 1986
replace legal_thresh = 5 if country_n == 43 & year >= 1954
replace legal_thresh = 3 if country_n == 45 & year > 1990
replace legal_thresh = 5 if country_n == 52 & year >= 2000
replace legal_thresh = 4 if country_n == 57 & year >= 1993
replace legal_thresh = 3 if country_n == 57 & year >= 2005
replace legal_thresh = 1 if country_n == 87 & year < 1956
replace legal_thresh = 0.67 if country_n == 87 & year >= 1956
replace legal_thresh = 5 if country_n == 88 & year >= 1996
replace legal_thresh = 4 if country_n == 92 & year >= 1989
replace legal_thresh = 3 if country_n == 115
replace legal_thresh = 4 if country_n == 122 & year >= 1969

generate threshold = .
replace threshold = legal_thresh if legal_thresh > effective_thresh
replace threshold = effective_thresh if threshold ==.
order threshold, after(legal_thresh)

gen lagged_tier1 =.
gen lagged_tier2 =.
gen lagged_decisive =.
gen lagged_legalthresh =.
gen lagged_effecthresh =.
gen lagged_thresh =.

bysort country_n (master_id): replace lagged_tier1 = tier1_avemag[_n-1]
bysort country_n (master_id): replace lagged_tier2 = tier2_avemag[_n-1]
bysort country_n (master_id): replace lagged_decisive = decisive[_n-1]
bysort country_n (master_id): replace lagged_legalthresh = legal_thresh[_n-1]
bysort country_n (master_id): replace lagged_effecthresh = effective_thresh[_n-1]
bysort country_n (master_id): replace lagged_thresh = threshold[_n-1]

drop presidential legislative_type elecrule tier1_formula tier2_formula tier3_formula ///
tier4_formula mixed_type multi multi_linked seats tier1_districts uppertier tier3_districts ///
tier4_districts enep_others enep1 enpp_others enpp1 enpres preselecrule region1 ///
region2 region3 aclp_code ccode ccode2 month day regime secondround thirdround

keep elec_id country country_n year tier1_avemag decisive threshold 



sort country year
gen counter = _n

gen unified_countrysurveyFE =.
order unified_country, after(counter)


replace unified_countrysurveyFE = 1 if country_n == 7 & year == 1996 //* Australia 96									 
replace unified_countrysurveyFE = 2 if country_n == 7 & year == 2004 //* Australia 04							
replace unified_countrysurveyFE = 3 if country_n == 7 & year == 2007 //* Australia 07	(1 37.5 1)
replace unified_countrysurveyFE = 4 if country_n == 7 & year == 2013 //* Australia 13
replace unified_countrysurveyFE = 5 if country_n == 8 & year == 2008 //* Austria 08									 
replace unified_countrysurveyFE = 6 if country_n == 8 & year == 2013 //* Austria 13	
replace unified_countrysurveyFE = 7 if country_n == 12 & year == 1999  //* Flanders 99	
replace unified_countrysurveyFE = 8 if country_n == 12 & year == 1999 //* Wallonia 99
replace unified_countrysurveyFE = 9 if country_n == 12 & year == 2003 //* Belgium 03					 
replace unified_countrysurveyFE = 10 if country_n == 20 & year == 1997 //* Canada 97  	 (1 37.5 1)
replace unified_countrysurveyFE = 11 if country_n == 20 & year == 2004 //* Canada 04	
replace unified_countrysurveyFE = 12 if country_n == 20 & year == 2008 //* Canada 08
replace unified_countrysurveyFE = 13 if country_n == 20 & year == 2011 //* Canada 11									 
replace unified_countrysurveyFE = 14 if country_n == 20 & year == 2015 //* Canada 15	
replace unified_countrysurveyFE = 15 if country_n == 123 & year == 1999 //* Switz 99	
replace unified_countrysurveyFE = 16 if country_n == 123 & year == 2003 //* Switz 03
replace unified_countrysurveyFE = 17 if country_n == 123 & year == 2007 //* Switz 07									 
replace unified_countrysurveyFE = 18 if country_n == 123 & year == 2011 //* Switz 11	
replace unified_countrysurveyFE = 19 if country_n == 43 & year == 2002 //* Germany 02	
replace unified_countrysurveyFE = 20 if country_n == 43 & year == 2002 //* Germany 02b
replace unified_countrysurveyFE = 21 if country_n == 43 & year == 2005 //* Germany 2005									 
replace unified_countrysurveyFE = 22 if country_n == 43 & year == 2009 //* Germany 2009							
replace unified_countrysurveyFE = 23 if country_n == 43 & year == 2013 //* Germany 2013	
replace unified_countrysurveyFE = 24 if country_n == 32 & year == 1998 //* Denmark 1998
replace unified_countrysurveyFE = 25 if country_n == 32 & year == 2001 //* Denmark 2001									 
replace unified_countrysurveyFE = 26 if country_n == 32 & year == 2007 //* Denmark 2007					
replace unified_countrysurveyFE = 27 if country_n == 115 & year == 1996 //* Spain 1996 	
replace unified_countrysurveyFE = 28 if country_n == 115 & year == 2000 //* Spain 2000
replace unified_countrysurveyFE = 29 if country_n == 115 & year == 2004 //* Spain 2004									 
replace unified_countrysurveyFE = 30 if country_n == 115 & year == 2008 //* Spain 2008			
replace unified_countrysurveyFE = 31 if country_n == 40 & year == 2003 //* Finland 2003	
replace unified_countrysurveyFE = 32 if country_n == 40 & year == 2007 //* Finland 2007
replace unified_countrysurveyFE = 33 if country_n == 40 & year == 2011 //* Finland 2011									 
replace unified_countrysurveyFE = 34 if country_n == 40 & year == 2015 //* Finland 2015	 (13.3 5.3 13.3)
replace unified_countrysurveyFE = 35 if country_n == 41 & year == 2007 //* France 2007	
replace unified_countrysurveyFE = 36 if country_n == 131 & year == 1997 //* Britain 1997
replace unified_countrysurveyFE = 37 if country_n == 131 & year == 2005 //* Britain 2005									 
replace unified_countrysurveyFE = 38 if country_n == 131 & year == 2015 //* Britain 2015	
replace unified_countrysurveyFE = 39 if country_n == 45 & year == 2009 //* Greece 2009	
replace unified_countrysurveyFE = 40 if country_n == 45 & year == 2012 //* Greece 2012
replace unified_countrysurveyFE = 41 if country_n == 45 & year == 2015 //* Greece 2015							 
replace unified_countrysurveyFE = 42 if country_n == 55 & year == 2002 //* Ireland 2002							
replace unified_countrysurveyFE = 43 if country_n == 55 & year == 2007 //* Ireland 2007	
replace unified_countrysurveyFE = 44 if country_n == 55 & year == 2011 //* Ireland 2011
replace unified_countrysurveyFE = 45 if country_n == 52 & year == 1999 //* Iceland 1999									 
replace unified_countrysurveyFE = 46 if country_n == 52 & year == 2003 //* Iceland 2003							
replace unified_countrysurveyFE = 47 if country_n == 52 & year == 2007 //* Iceland 2007	
replace unified_countrysurveyFE = 48 if country_n == 52 & year == 2009 //* Iceland 2009
replace unified_countrysurveyFE = 49 if country_n == 52 & year == 2013 //* Iceland 2013									 
replace unified_countrysurveyFE = 50 if country_n == 57 & year == 2006 //* Italy 2006	
replace unified_countrysurveyFE = 51 if country_n == 87 & year == 1998 //* Netherlands 1998	
replace unified_countrysurveyFE = 52 if country_n == 87 & year == 2002 //* Netherlands 2002
replace unified_countrysurveyFE = 53 if country_n == 87 & year == 2006 //* Netherlands 2006									 
replace unified_countrysurveyFE = 54 if country_n == 87 & year == 2010 //* Netherlands 2010					
replace unified_countrysurveyFE = 55 if country_n == 92 & year == 1997 //* Norway 1997	
replace unified_countrysurveyFE = 56 if country_n == 92 & year == 2001 //* Norway 2001
replace unified_countrysurveyFE = 57 if country_n == 92 & year == 2005 //* Norway 2005									 
replace unified_countrysurveyFE = 58 if country_n == 92 & year == 2009 //* Norway 2009							
replace unified_countrysurveyFE = 59 if country_n == 92 & year == 2013 //* Norway 2013	
replace unified_countrysurveyFE = 60 if country_n == 88 & year == 1996 //* NZ 1996
replace unified_countrysurveyFE = 61 if country_n == 88 & year == 2002 //* NZ 2002									 
replace unified_countrysurveyFE = 62 if country_n == 88 & year == 2008 //* NZ 2008							
replace unified_countrysurveyFE = 63 if country_n == 88 & year == 2011 //* NZ 2011	
replace unified_countrysurveyFE = 64 if country_n == 88 & year == 2014 //* NZ 2014  (50 5 1)
replace unified_countrysurveyFE = 65 if country_n == 101 & year == 2002 //* Portugal 2002									 
replace unified_countrysurveyFE = 66 if country_n == 101 & year == 2005 //* Portugal 2005							
replace unified_countrysurveyFE = 67 if country_n == 101 & year == 2009 //* Portugal 2009	
replace unified_countrysurveyFE = 68 if country_n == 101 & year == 2015 //* Portugal 2015
replace unified_countrysurveyFE = 69 if country_n == 122 & year == 1998 //* Sweden 1998									 
replace unified_countrysurveyFE = 70 if country_n == 122 & year == 2002 //* Sweden 2002							
replace unified_countrysurveyFE = 71 if country_n == 122 & year == 2006 //* Sweden 2006	
replace unified_countrysurveyFE = 72 if country_n == 122 & year == 2014 //* Sweden 2014 (39 4 11)
replace unified_countrysurveyFE = 73 if country_n == 43 & year == 1998 //* Germany 1998 (21.3 5 1))

drop if counter == 185 | counter == 188 

drop if unified_ ==.

save "$data2\PolData_Mergable3.dta", replace
clear

use "$data2\CSESedit.dta"
drop _merge
merge m:1 unified_countrysurveyFE using "$data2\PolData_Mergable3.dta", force
 
 
  
** Copying in correct values where pairs in the above **
 
replace decisive  =   10.45     if unified_countrysurveyFE == 68 //* Portugal 15
replace threshold =    6.550219 if unified_countrysurveyFE == 68
replace tier1_avemag = 10.45    if unified_countrysurveyFE == 68

replace decisive  =   5.14     if unified_countrysurveyFE == 41 //* Greece 15
replace threshold =   12.21498     if unified_countrysurveyFE == 41
replace tier1_avemag = 5.14    if unified_countrysurveyFE == 41
  
replace decisive  =  1      if unified_countrysurveyFE == 38 //* Britain 15
replace threshold =  37.5      if unified_countrysurveyFE == 38
replace tier1_avemag = 1    if unified_countrysurveyFE == 38
  
replace decisive  =   19     if unified_countrysurveyFE == 19 //* Germany 2002
replace threshold =   5     if unified_countrysurveyFE == 19
replace tier1_avemag = 1    if unified_countrysurveyFE == 19

replace decisive  =  39      if unified_countrysurveyFE == 72 //* Sweden 14
replace threshold =   4     if unified_countrysurveyFE == 72
replace tier1_avemag = 10.7    if unified_countrysurveyFE == 72
  
replace decisive  = 4.26       if unified_countrysurveyFE == 6 //* Austria 13
replace threshold =  14.25855      if unified_countrysurveyFE == 6
replace tier1_avemag = 4.26    if unified_countrysurveyFE == 6    
  
replace decisive  = 7.5       if unified_countrysurveyFE == 7 //* Flanders 99
replace threshold =  8.823529      if unified_countrysurveyFE == 7
replace tier1_avemag =  7.5   if unified_countrysurveyFE == 7
  
replace decisive  = 20.6875       if unified_countrysurveyFE == 23 //* Germany 13
replace threshold =  5      if unified_countrysurveyFE == 23
replace tier1_avemag = 1    if unified_countrysurveyFE == 23 
  
replace decisive  =  13.3      if unified_countrysurveyFE == 34 //* Finland 15
replace threshold =   5.244755     if unified_countrysurveyFE == 34
replace tier1_avemag =   13.3  if unified_countrysurveyFE == 34   
  
  

gen log_DM_decisivetier = ln(decisive)
gen log_threshold = ln(threshold)
gen log_DM_lowertier = ln(tier1_avemag)

label variable log_DM_decisivetier
label variable log_threshold
label variable log_DM_lowertier
 
 rename lag_rgdpnaPC LEVEL2_GDPpcLag
 rename lag2GR_rgdpnaPC LEVEL2_EconGrowthLag
 rename log_threshold LEVEL2_ElectoralThresholdLog

 order LEVEL2_EconGrowthLag LEVEL2_GDPpcLag LEVEL2_ElectoralThresholdLog, after(unified_econpos)

label variable LEVEL2_EconGrowthLag "Lagged Economic Growth Rate (GDPpc % change equiv)"
label variable LEVEL2_GDPpcLag  "Lagged Economic Level (GDPpc equiv)"
label variable LEVEL2_ElectoralThresholdLog  "Electoral Threshold - Legal or Effective, Whichever Higher"

label variable psGEN_Polarisation_DALTON "Mainstream Party Polarisation (CMP, Objective)"
rename psGEN_Polarisation_DALTON LEVEL2_MSPOLAR
replace LEVEL2_MSPOLAR = LEVEL2_MSPOLAR * 10

order LEVEL2_MSPOLAR, after(LEVEL2_ElectoralThresholdLog)
 
 numlabel, add force

 tab unified_age4cat, generate(age4)
 tab unified_education3cat, gen(educ3)
 tab unified_partisanship, gen(PID6)
 tab cses_income_group_5, gen(income5)
 tab unified_partisanship2, gen(PID5)
 
 gen Interaction_PolarGrowth = unified_MSpolarisation * LEVEL2_EconGrowthLag
 gen Interaction_EconVoteConverge = unified_econpos * LEVEL2_MSPOLAR
 
 label variable Interaction_PolarGrowth "Subj. Polarisation * Objective Growth Interaction" 
 label variable Interaction_EconVoteConverge "Obj. Polarisation * Sujective Econ Rating Interaction" 
  
 save "$data2\study2dataFULL.dta", replace
 
 drop cses_*
 drop master_id countrycode year country pop rgdpna country_n PC_rgdpna edate ///
 psECON_Polarisation_DALTON psSOC_Polarisation_DALTON ms_bigrange ms_maxrange ///
 counter elec_id decisive threshold tier1_avemag _merge log_DM_decisivetier log_DM_lowertier
 
 STOP
 
 

  
*******************************************************************************************************************************************************************************************   

************************************************************************* MAIN ARTICLE MODELS **********************************************************************************************   
 
  
******************************* TABLE 2  ***********************************  
  
  
* Model C
gllamm unified_votechoice unified_MSpolarisation LEVEL2_EconGrowthLag Interaction_PolarGrowth unified_gender age41 age42 age44 educ31 educ33 income51 income52 income54 income55 unified_selfradical PID62 PID63 PID64 PID65 PID66, base(1) link(mlogit) fam(binomial) i(unified_countrysurveyFE) nip(8) adapt dots
gen in_model_1 =e(sample)

* Null Model
gllamm unified_votechoice                                                                                                                                                                                                                                  if in_model_1 == 1, base(1) link(mlogit) fam(binomial) i(unified_countrysurveyFE) nip(8) adapt dots
* Model A                                                                                          
gllamm unified_votechoice unified_MSpolarisation LEVEL2_EconGrowthLag Interaction_PolarGrowth                                                                                                                                                              if in_model_1 == 1, base(1) link(mlogit) fam(binomial) i(unified_countrysurveyFE) nip(8) adapt dots
* Model B    
gllamm unified_votechoice unified_MSpolarisation LEVEL2_EconGrowthLag Interaction_PolarGrowth  unified_gender age41 age42 age44 educ31 educ33 income51 income52 income54 income55                                                                          if in_model_1 == 1, base(1) link(mlogit) fam(binomial) i(unified_countrysurveyFE) nip(8) adapt dots



*******************************  TABLE 3 ***********************************


gllamm unified_votechoice unified_econpos LEVEL2_MSPOLAR Interaction_EconVoteConverge unified_gender age41 age42 age44 educ31 educ33 income51 income52 income54 income55 unified_selfradical PID62 PID63 PID64 PID65 PID66, base(1) link(mlogit) fam(binomial) i(unified_countrysurveyFE) nip(8) adapt dots
gen in_model_2 =e(sample)

* Null Model
gllamm unified_votechoice                                                                                                                                                                                                    if in_model_2 == 1, base(1) link(mlogit) fam(binomial) i(unified_countrysurveyFE) nip(8) adapt dots
* Model A
gllamm unified_votechoice unified_econpos LEVEL2_MSPOLAR Interaction_EconVoteConverge                                                                                                                                 if in_model_2 == 1, base(1) link(mlogit) fam(binomial) i(unified_countrysurveyFE) nip(8) adapt dots
* Model B
gllamm unified_votechoice unified_econpos LEVEL2_MSPOLAR Interaction_EconVoteConverge  unified_gender age41 age42 age44 educ31 educ33 income51 income52 income54 income55                                             if in_model_2 == 1, base(1) link(mlogit) fam(binomial) i(unified_countrysurveyFE) nip(8) adapt dots


 


******************************************************** ARTICLE APPENDIX *******************************************
 



 *** Table F.1:  Rep of Table 2 with 5 Category DV

gllamm unified_votechoice2 unified_MSpolarisation LEVEL2_EconGrowthLag Interaction_PolarGrowth unified_gender age41 age42 age44 educ31 educ33 income51 income52 income54 income55 unified_selfradical PID52 PID53 PID54 PID55, base(1) link(mlogit) fam(binomial) i(unified_countrysurveyFE) nip(8) adapt dots
gen in_model_3 =e(sample)

gllamm unified_votechoice2                                                                                                                                                                                                                                  if in_model_3 == 1, base(1) link(mlogit) fam(binomial) i(unified_countrysurveyFE) nip(8) adapt  dots

gllamm unified_votechoice2 unified_MSpolarisation LEVEL2_EconGrowthLag Interaction_PolarGrowth                                                                                                                                                              if in_model_3 == 1, base(1) link(mlogit) fam(binomial) i(unified_countrysurveyFE) nip(8) adapt  dots

gllamm unified_votechoice2 unified_MSpolarisation LEVEL2_EconGrowthLag Interaction_PolarGrowth  unified_gender age41 age42 age44 educ31 educ33 income51 income52 income54 income55                                             if in_model_3 == 1, base(1) link(mlogit) fam(binomial) i(unified_countrysurveyFE) nip(8) adapt  dots


 
  *** Table F.2:  Rep of Table 2 with Upper-Level Controls 

  
 * Model C
gllamm unified_votechoice unified_MSpolarisation LEVEL2_EconGrowthLag Interaction_PolarGrowth LEVEL2_GDPpcLag LEVEL2_ElectoralThresholdLog unified_gender age41 age42 age44 educ31 educ33 income51 income52 income54 income55 unified_selfradical PID62 PID63 PID64 PID65 PID66, base(1) link(mlogit) fam(binomial) i(unified_countrysurveyFE) nip(8) adapt dots
gen in_model_4 =e(sample)

* Null Model
gllamm unified_votechoice                                                                                                                                                                                                                                  if in_model_4 == 1, base(1) link(mlogit) fam(binomial) i(unified_countrysurveyFE) nip(8) adapt dots
* Model A                                                                                          
gllamm unified_votechoice unified_MSpolarisation LEVEL2_EconGrowthLag Interaction_PolarGrowth LEVEL2_GDPpcLag LEVEL2_ElectoralThresholdLog                                                                                                                                                             if in_model_4 == 1, base(1) link(mlogit) fam(binomial) i(unified_countrysurveyFE) nip(8) adapt dots
* Model B    
gllamm unified_votechoice unified_MSpolarisation LEVEL2_EconGrowthLag Interaction_PolarGrowth LEVEL2_GDPpcLag LEVEL2_ElectoralThresholdLog unified_gender age41 age42 age44 educ31 educ33 income51 income52 income54 income55                                                                          if in_model_4 == 1, base(1) link(mlogit) fam(binomial) i(unified_countrysurveyFE) nip(8) adapt dots


 
 
*** Table F.4: Rep of Table 3 with 5-Category DV

gllamm unified_votechoice2 unified_econpos LEVEL2_MSPOLAR Interaction_EconVoteConverge unified_gender age41 age42 age44 educ31 educ33 income51 income52 income54 income55 unified_selfradical PID52 PID53 PID54 PID55, base(1) link(mlogit) fam(binomial) i(unified_countrysurveyFE) nip(8) adapt  dots
gen in_model_5 =e(sample)

gllamm unified_votechoice2                                                                                                                                                                                             if in_model_5 == 1, base(1) link(mlogit) fam(binomial) i(unified_countrysurveyFE) nip(8) adapt  dots

gllamm unified_votechoice2 unified_econpos LEVEL2_MSPOLAR Interaction_EconVoteConverge                                                                                                                                 if in_model_5 == 1, base(1) link(mlogit) fam(binomial) i(unified_countrysurveyFE) nip(8) adapt  dots

gllamm unified_votechoice2 unified_econpos LEVEL2_MSPOLAR Interaction_EconVoteConverge  unified_gender age41 age42 age44 educ31 educ33 income51 income52 income54 income55                                             if in_model_5 == 1, base(1) link(mlogit) fam(binomial) i(unified_countrysurveyFE) nip(8) adapt  dots


 
 
 *** Table F.5: Rep of Table 3 with Upper-Level Controls
 
gllamm unified_votechoice unified_econpos LEVEL2_MSPOLAR Interaction_EconVoteConverge LEVEL2_GDPpcLag LEVEL2_ElectoralThresholdLog unified_gender age41 age42 age44 educ31 educ33 income51 income52 income54 income55 unified_selfradical PID62 PID63 PID64 PID65 PID66, base(1) link(mlogit) fam(binomial) i(unified_countrysurveyFE) nip(8) adapt dots
gen in_model_6 =e(sample)

* Null Model
gllamm unified_votechoice                                                                                                                                                                                                    if in_model_6 == 1, base(1) link(mlogit) fam(binomial) i(unified_countrysurveyFE) nip(8) adapt dots
* Model A
gllamm unified_votechoice unified_econpos LEVEL2_MSPOLAR Interaction_EconVoteConverge  LEVEL2_GDPpcLag LEVEL2_ElectoralThresholdLog                                                                                                                                if in_model_6 == 1, base(1) link(mlogit) fam(binomial) i(unified_countrysurveyFE) nip(8) adapt dots
* Model B
gllamm unified_votechoice unified_econpos LEVEL2_MSPOLAR Interaction_EconVoteConverge  LEVEL2_GDPpcLag LEVEL2_ElectoralThresholdLog unified_gender age41 age42 age44 educ31 educ33 income51 income52 income54 income55                                             if in_model_6 == 1, base(1) link(mlogit) fam(binomial) i(unified_countrysurveyFE) nip(8) adapt dots


 




